从今天开始,我在使用 ASP.NET MVC 的 IIS7.5 上遇到异常,但我不知道为什么。
它在使用 System.Net.WebClient.DownloadString() 时发生
[WebException:远程服务器返回错误:(500)内部服务器错误。]
如果我在浏览器中打开 URL。网站显示正常。
在 VS2008 调试跟踪状态为:“200 OK”
它唯一能看到的是:
Response.Headers”的类型异常“System.PlatformNotSupportedException”导致。System.Collections.Specialized.NameValueCollection {System.PlatformNotSupportedException}
请在 IIS 中使用集成管道模式。
两个网站都在启用了集成管道的同一个 v2.0 .NET 应用程序池中运行。来自例如 google.com 等的 DownloadString 有效。只有当我调用 MVC 时它才会损坏。
MVC 中调用的控制器如下所示:
public void online()
{
Response.Write(Date.Time.Now);
Response.End();
return;
}
它以前工作过。可能有人可以帮助获取更多详细信息以追踪错误。
更新:
知道了。该死的。我检查了 ASP.NET MVC 中的 Subversion History 并检查了每一行。在我的 BaseController 中,我最近添加了:
string strUserAgent = Request.UserAgent.ToString().ToLower();
删除后。一切都恢复正常。但是为什么 System.Net.WebClient 在请求 UserAgent 时会崩溃?即使有 200 状态。我将对此进行一些调查。