Too*_*eey 3 asp.net asp.net-mvc azure
几天来,我一直在撞击这头,没有任何地方.我希望有一个捕获所有错误处理程序,重定向到控制器,向用户显示一个整洁的页面,以及执行相关的日志记录等.
问题是本地一切都很好,但是当我上传到azure时,我会得到标准的错误页面.
似乎azure不执行重定向,并忽略global.asax中的全局处理程序.
我没有在这里包含错误控制器的代码,因为我似乎从来没有这么远.
Web.Config中:
<customErrors mode="On" defaultRedirect="/error" redirectMode="ResponseRewrite"></customErrors>
路线入口:
routes.MapRoute("Error", "error/{*fluff}", new { controller = "Error", action = "Index", exception = new HttpException(404,"Direct call to controller") });
来自global.asax:
protected void Application_Error(object sender, EventArgs e)
{
var routeData = new RouteData();
routeData.Values["controller"] = "Error";
routeData.Values["action"] = "index";
routeData.Values["exception"] = Server.GetLastError();
Response.Clear();
Server.ClearError();
IController controller = new ErrorController();
controller.Execute(new RequestContext(new HttpContextWrapper(((MvcApplication)sender).Context), routeData));
}
Run Code Online (Sandbox Code Playgroud)
小智 5
尝试将 existingResponse 设置为 PassThrough,如下所示:
<httpErrors existingResponse="PassThrough"/>
Run Code Online (Sandbox Code Playgroud)
来源:http : //blog.dezfowler.com/2010/09/aspnet-custom-error-not-shown-in-azure.html
这样做的伎俩:
Response.TrySkipIisCustomErrors = true;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1159 次 |
| 最近记录: |