當網站出錯時有問題卻沒有紀錄怎麼辦?用Application_Error
來Hold住全場吧 !!
- Global.asax
1234567891011121314protected void Application_Error(object sender, EventArgs e){var rawUrl = Request.RawUrl;var ex = Server.GetLastError();Debug.WriteLine("RawUrl: {0}", rawUrl);Debug.WriteLine("Ex: {0}", ex.Message);Debug.WriteLine("StackTrace: {0}", ex.StackTrace);//若網頁沒有撰寫任何的錯誤處理,或是沒有回收清除(Server.ClearError),最後將顯示預設錯誤畫面;反之若有清除則不再往下一個除錯流程。Server.ClearError();//導回首頁Response.Redirect("/");}