我不得不重新构建我的整个应用程序,从 VS Express DB 到使用 Visual Studio 2012。我必须删除所有模式并重新添加它们。
现在,当我尝试运行该应用程序时,它一直在 Global.Asax.cs
它不断抛出 NullReferenceException --> int exceptionType = httpException.GetHttpCode();
我的应用程序甚至没有运行,似乎本地主机服务器甚至没有加载我的网站
请帮忙
protected void Application_Error()
{
if (Context.IsCustomErrorEnabled)
ShowCustomErrorPage(Server.GetLastError());
}
private void ShowCustomErrorPage(Exception exception)
{
var httpException = exception as HttpException;
if (exception != null)
{
exception = httpException;
}
else
{
exception = new HttpException(500, "Internal Server Error", exception);
}
Response.Clear();
Server.ClearError();
var routeData = new RouteData();
routeData.Values.Add("Controller", "Error");
routeData.Values.Add("fromAppErrorEvent", true);
int exceptionType = httpException.GetHttpCode();
switch (exceptionType)
{
case 403:
routeData.Values.Add("action", "HttpError403");
break;
case 404:
routeData.Values.Add("action", "NotFound");
break;
case 500:
routeData.Values.Add("action", "HttpError500");
break;
default:
routeData.Values.Add("action", "GeneralError");
routeData.Values.Add("httpStatusCode", httpException.GetHttpCode());
break;
}
IController controller = new Login.Controllers.ErrorController();
controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));