views:

181

answers:

1

Hi,

since today i get an Exception on IIS7.5 with ASP.NET MVC, but i dont know why.

It occurs while using System.Net.WebClient.DownloadString()

[WebException: The remote server returned an error: (500) Internal Server Error.]

If I open URL in Browser. Site shows up fine.

In VS2008 Debug Trace Status is: "200 OK"

The only thing it could see was:

Response.Headers" of Type Exception "System.PlatformNotSupportedException" caused. System.Collections.Specialized.NameValueCollection {System.PlatformNotSupportedException}

Please use integrated Pipeline Mode in IIS.

Both Website run within the same v2.0 .NET Application Pool with Integrated Pipeline enabled. DownloadString from e.g. google.com etc works. Only if I call the MVC it corrupts.

Called Controller in MVC looks like this:

    public void online()
    {
        Response.Write(Date.Time.Now);
        Response.End();
        return;
    }

It worked before. May someone can help to get more details to track down the error.

UPDATE:

Got it. Damn it. I checked Subversion History in ASP.NET MVC an checked every line. In my BaseController, i added recently:

string strUserAgent = Request.UserAgent.ToString().ToLower();

After remove. Everything works again. But why is System.Net.WebClient crashing when asking for UserAgent? Even with 200 Status. I'll give this a little investigation.

A: 

In my case this does the trick:

if (Request.UserAgent != null)
{
  string strUserAgent = Request.UserAgent.ToString().ToLower();
}

but its quite stuipid of System.Net.WebClient to throw an Exception when Webserver is doing Request.UserAgent even there is HTTP Status 200.

csharpnoob