2012-02-07 51 views
0

的Application_Error未發佈任何網站,我也取得了自定義錯誤模式的web配置關閉,燒成後僅遠程我也把下面的代碼在Application_Error事件Applicaion_Error事件在Global.asax中

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); 

} 

回答

1

請檢查以下代碼

var error = Server.GetLastError(); var code =(錯誤是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); 

} 

條件的必須是同等條件下在同等條件

陳述
相關問題