Asp.net Global.asax中的应用程序错误事件
发布网站后,应用程序_错误未触发。我还关闭了web配置中的自定义错误模式,仅远程。我还将以下代码放入了应用程序_错误事件中Asp.net Global.asax中的应用程序错误事件,asp.net,Asp.net,发布网站后,应用程序_错误未触发。我还关闭了web配置中的自定义错误模式,仅远程。我还将以下代码放入了应用程序_错误事件中 var error = Server.GetLastError(); var code = (error is HttpException) ? (error as HttpException).GetHttpCode() : 500; if (code != 404 || code!=301 ||code!=302 ) { System.Web.HttpAppl
var error = Server.GetLastError();
var code = (error is HttpException) ? (error as HttpException).GetHttpCode() : 500;
if (code != 404 || code!=301 ||code!=302 )
{
System.Web.HttpApplication app = (System.Web.HttpApplication)sender;
string requestedUrl = app.Request.Path.ToLower();
RequestUrls = requestedUrl;
string realUrl = GetRealUrl(requestedUrl.ToLower());
Server.ClearError();
if (!String.IsNullOrEmpty(realUrl))
Response.RedirectPermanent(realUrl,true);
}
请检查以下代码 var error=Server.GetLastError(); var代码=(错误为HttpException)?(错误为HttpException)。GetHttpCode():500 它们的条件必须是相等的,条件是在相等的条件下声明的
if (code == 404 || code==301 ||code==302 )
{
System.Web.HttpApplication app = (System.Web.HttpApplication)sender;
string requestedUrl = app.Request.Path.ToLower();
RequestUrls = requestedUrl;
string realUrl = GetRealUrl(requestedUrl.ToLower());
Server.ClearError();
if (!String.IsNullOrEmpty(realUrl))
Response.RedirectPermanent(realUrl,true);
}