【发布时间】:2010-12-24 01:22:28
【问题描述】:
我遵循了有关如何设置 404 的建议:
http://www.andornot.com/about/developerblog/archive/2009_10_01_archive.aspx
及相关:
Best way to implement a 404 in ASP.NET
来自 Global.asax:
protected void Application_Error(Object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
if (exception is HttpUnhandledException)
{
if (exception.InnerException == null)
{
Server.Transfer(string.Format("~/Error.aspx", false));
return;
}
exception = exception.InnerException;
}
if (exception is HttpException)
{
if (((HttpException)exception).GetHttpCode() == 404)
{
Server.ClearError();
Server.Transfer("~/404.aspx", false);
return;
}
}
if (Context != null && Context.IsCustomErrorEnabled)
{
Server.Transfer(string.Format("~/Error.aspx"), false);
}
}
并且来自 Web.config:
<customErrors mode="On"/>
在测试(VS2010)时它在本地运行良好,但在生产中(ISS6)它只适用于 aspx 页面。 http://mysite.se/foo.js 给我 ISS 404 页面。 ("找不到页面")
我错过了什么?
【问题讨论】:
标签: asp.net iis-6 http-status-code-404