사용자 지정 오류 처리기를 사용했습니다.
는 Global.asax.cs에 다음 코드를 추가합니다 :
나는 또한 사용자가 슈퍼 유저 인 경우를 제외하고 세부 정보를 표시하는 내 오류 페이지에 사용자 지정 코드를 추가
protected void Application_Error()
{
// if the debugger is attached, do not show the custom error page
if (System.Diagnostics.Debugger.IsAttached)
{
return;
}
try
{
Exception exception = Server.GetLastError();
Response.Clear();
Server.ClearError();
RouteData routeData = new RouteData();
routeData.Values["controller"] = "MyCustomErrorController";
routeData.Values["action"] = "Index";
routeData.Values["exception"] = exception;
IController errorsController = new MyCustomErrorController();
var rc = new RequestContext(new HttpContextWrapper(Context), routeData);
errorsController.Execute(rc);
}
catch (Exception ex)
{
// if an error occurs within this method, do nothing
// app will automatically show the browser's default error page
}
}
. 따라서 디버그 모드 나 라이브 사이트에 있지 않은 경우 (관리자로 로그인 한 경우) 오류 세부 정보를 쉽게 볼 수 있습니다.
코드를 더 잘 이해하려면 google을 사용하거나 디버거를 사용하여 단계별로 수행하십시오.
감사합니다. 그러나 이것은 내가 원하는 것이 아닙니다. 구문 오류 '온라인'같은 것을보고 싶습니다 : 줄 23 : // 예외 또는 오류 – Bellash
또한 ELMAH를 확인하십시오 : http://code.google.com/p/elmah/ 오류 로거를 사용하기가 간단합니다. , Nuget 패키지에서 직접 설치할 수 있습니다 : http://nuget.org/packages/elmah/ – amhed