简体   繁体   中英

ASP.NET MVC Exception?

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 eg 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM