简体   繁体   中英

Link from ASP.NET yellow error page directly to VS source code

When an ASP.NET application errors out and generates the yellow-screen display, I'd like to create some kind of link from the error page which would jump directly to the correct line of code in Visual Studio.

I'm not sure how to approach this, or if there are any tools already in existence which accomplish it - but I'd love some feedback on where to start.

In the event that generating a new error page is necessary, is it possible to replace the standard yellow screen across an entire webserver, rather than having to configure the customized error output for each application?

您可能需要在页面中嵌入ActiveX控件,这样才能实现。

The yellow screen of death is served by the default ASP.NET HTTPHandler.

In order to intercept it, you would need to add another HTTPHandler in front of it that intercepts all uncaught exceptions.

At that point, you could do whatever you want for your error layout.

Creating a way to directly jump to Visual Studio would be tricky. I could see it done in IE via a COM/ActiveX object.

The yellow screen of death is just a 500 error as far as the server is concerned, you can redirect to a custom screen using the error section of the web.config. To make a whole server change in the same manner you could probably override it at the iis level? Or perhaps even set the default behaviour in the machine.config file (not 100% sure about that one though)

The yellow screen of death is just a 500 error as far as the server is concerned, you can redirect to a custom screen using the error section of the web.config. To make a whole server change in the same manner you could probably override it at the iis level? Or perhaps even set the default behaviour in the machine.config file (not 100% sure about that one though)

If you let it bubble up all the way to IIS you will not have any way to access the Exception information. Its better to catch the Exception before the YSOD and serve your own.

This can be done at the application level.

Don't forget that you need the Program Debug Database (pdb) file to find the source code line number. An application in release mode won't have the same level of information as a debug release.

The easiest, laziest thing I could think of would be to have the process happen thusly:

  1. The yellow screen is modified so the line is source code is clickable. When clicked it delivers a small text file with the source file name and line number.
  2. A small program on the PC is tied to the extension of the small file the yellow screen let you download. The program uses visual studio's extensibility model to open the source file and goto that line. The program may need to know where your source code is.

A simple Google search gives helpful pointers on how to manipulate VS with an external program such as this post on MSDN .

If you want to go snazzier, then there are certainly other methods, but I'd rather write out a quick and dirty program, and get it out of my way so I can be about my business.

Don't let the tools become projects...

-Adam

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM