在我的 Asp.Net MVC 项目中,我正在处理 Http FileNotFound 异常(对于丢失的图像),然后将请求重定向到默认图像,如下所示
protected void Application_Error(object sender, EventArgs e)
{
if (Request.Path.StartsWith("/images/profile"))
{
Response.Redirect("/images/profile/default.jpg", true);
return;
}
}
当我调试我的网站时,它正在开发环境中工作。但是当我将它部署到运行 IIS 7.5 的生产服务器时,此代码不起作用,对图像文件的请求不会触发 Application_Error 事件。IIS上有什么配置吗?我找不到问题。