I have an ASP.NET web form application. In the web.config file associated with this application, I handle my own error as follows:
<customErrors mode="Off" defaultRedirect="error.aspx" />
When the user gets to the error.aspx page, I want to determine what error led to reaching this page. Does anyone know how I can do this?
Thank!
You can do this using the Server.GetLastError Method
Exception LastError; String ErrMessage; LastError = Server.GetLastError(); if (LastError != null) ErrMessage = LastError.Message; else ErrMessage = "No Errors"; Response.Write("Last Error = " + ErrMessage);
You get the exception object using the method GetLastError:
GetLastError
Exception ex = Server.GetLastError();
(Copied directly from the code of our error page, on which several million errors have been registered so far ... :)
Source: https://habr.com/ru/post/1763604/More articles:What is the fastest way to concatenate strings in PHP? - phpArtificial Intelligence Curriculum Helps Idea and Its Influence on a Later Master's Degree - Artificial-Intelligenceскрыть контроллер панели отображения - изнутри контроллера просмотра В контроллере панели вкладок - iphoneHow to sign a script or web page requiring UniversalXPConnect privilege - javascriptStruts2: Get the URL from which the user came - javaProcessUserAuthorization is always null - openidIs there a name for that kind? - sortingC ++ formatting date format - c ++Сравнение с плавающей точкой в VB6 - equalityIs this the name of the car or what? - dnsAll Articles