Fork me on GitHub

MVC错误处理

Global.asax.cs中添加如下的代码:

protected void Application_Error(Object sender, EventArgs e)
{
    Exception lastError = Server.GetLastError();
    if (lastError != null)
    {
        Response.StatusCode = 500;
        Response.WriteFile("~/error/error.htm");
        Server.ClearError();
    }                        
}

 

posted @ 2012-11-20 17:34  逗豆豆  阅读(151)  评论(0编辑  收藏  举报