In order to give the user an acceptable prompt interface when there is a problem with the system, and provide the first-hand information for later maintenance to write error logs
Captures and records at the global level in the web system.
[CSHARP]View plaincopyprint?
- Protected void application_error (Object sender, eventargs E)
- {
- Exception EX = server. getlasterror (). getbaseexception ();
- If (ex! = NULL)
- Pubfunction. errorlogprint (ex. stacktrace + ":" + ex. targetsite. Name, Ex. Message); // write the Error Log
- Response. Redirect ("~ /404. aspx "); // steering prompt page
- }
Protected void application_error (Object sender, eventargs e) {exception EX = server. getlasterror (). getbaseexception (); If (ex! = NULL) pubfunction. errorlogprint (ex. stacktrace + ":" + ex. targetsite. Name, Ex. Message); // write the Error Log Response. Redirect ("~ /404. aspx "); // steering prompt page}
Only in the last two days, a large number of logs are recorded in the error log as follows:
[HTML]View plaincopyprint?
-
- ----------------------------- 2012-03-22 17:08:57 ---------------------------
- Statement where an error occurs: In system. Web. staticfilehandler. getfileinfo (string virtualpathwithpathinfo, string physicalpath, httpresponse response)
-
- In system. Web. staticfilehandler. processrequestinternal (httpcontext context)
-
- In system. Web. defaulthttphandler. beginprocessrequest (httpcontext context, asynccallback callback, object state)
-
- In system. Web. httpapplication. callhandlerexecutionstep. system. Web. httpapplication. iexecutionstep. Execute ()
-
- In system. Web. httpapplication. executestep (iexecutionstep step, Boolean & completedsynchronously): getfileinfo
-
- Error message: the file does not exist.
-
- ----------------------------- 2012-03-22 17:09:26 ---------------------------
-
- Statement where an error occurs: In system. Web. staticfilehandler. getfileinfo (string virtualpathwithpathinfo, string physicalpath, httpresponse response)
- In system. Web. staticfilehandler. processrequestinternal (httpcontext context)
-
- In system. Web. defaulthttphandler. beginprocessrequest (httpcontext context, asynccallback callback, object state)
-
- In system. Web. httpapplication. callhandlerexecutionstep. system. Web. httpapplication. iexecutionstep. Execute ()
-
- In system. Web. httpapplication. executestep (iexecutionstep step, Boolean & completedsynchronously): getfileinfo
-
- Error message: the file does not exist.
----------------------------- 2012-03-22 17:08:57 ----------------------------- the wrong statement occurs: in the system. web. staticfilehandler. getfileinfo (string virtualpathwithpathinfo, string physicalpath, httpresponse response) in system. web. staticfilehandler. processrequestinternal (httpcontext context) in system. web. defaulthttphandler. beginprocessrequest (httpcontext context, asynccallback callback, object state) in system. we B. httpapplication. callhandlerexecutionstep. system. web. httpapplication. iexecutionstep. execute () in system. web. httpapplication. executestep (iexecutionstep step, Boolean & completedsynchronously): getfileinfo error message: the file does not exist. ----------------------------- 2012-03-22 17:09:26 ----------------------------- the wrong statement occurs: in the system. web. staticfilehandler. getfileinfo (string virtualpathwithpathinfo, string physicalpath, httpresponse response) in system. web. staticfilehandler. processrequestinternal (httpcontext context) in system. web. defaulthttphandler. beginprocessrequest (httpcontext context, asynccallback callback, object state) in system. W EB. httpapplication. callhandlerexecutionstep. system. web. httpapplication. iexecutionstep. execute () in system. web. httpapplication. executestep (iexecutionstep step, Boolean & completedsynchronously): getfileinfo error message: the file does not exist.
However, the website can work normally and does not go to the error page, which is very tangled.
1. Hit the breakpoint
[CSHARP]View plaincopyprint?
- Exception EX = server. getlasterror (). getbaseexception ();
Exception EX = server. getlasterror (). getbaseexception (); in this section, you can check the variables in time and view the stack information without obtaining valuable information.
The following message is displayed at http://forums.asp.net/t/1360302.aspx.
2. During the debugging process, directly track the information at the level of server-> non-public members-> _ context-> request-> apprelativecurrentexecutionfilepath. In this information
Finally, the path of an image is found, and the path of the image has changed.
3. At the project level, find the place where the image is used and correct the path.
4. I finally stopped recording this error ......
Today there is another problem, and the error log is as old as the above log records, and it is hard to understand.
Similarly, find a new thing according to the above process "~ /Favicon. ICO "Is this a magic horse? I don't remember using it in my website.
Fortunately, find the information here ,"~ /Favicon. ICO "is the website icon, which is the small icon before the title in the page header.
It's easy to find the problem. Create an icon file and put it under the root directory of the website. This error log does not exist. When you browse the page of the website, there are icons.
The effect is as follows:
Logistics Distribution Network http://wlphw.com/QQ online: 471226865