从 ASP.NET 黄色错误页面直接链接到 VS 源代码
当 ASP.NET 应用程序出错并生成黄屏显示时,我想从错误页面创建某种链接,该链接将直接跳转到 Visual Studio 中的正确代码行。
我不确定如何解决这个问题,或者是否已经存在任何工具可以实现它 - 但我希望得到一些关于从哪里开始的反馈。
如果需要生成新的错误页面,是否可以替换整个网络服务器上的标准黄屏,而不必为每个应用程序配置自定义错误输出?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可能需要在页面中嵌入 ActiveX 控件才能实现类似的操作。
You would probably need to embed an ActiveX control in the page for something like that to be possible.
就服务器而言,黄屏死机只是一个 500 错误,您可以使用 web.config 的错误部分重定向到自定义屏幕。 要以相同的方式更改整个服务器,您可能可以在 iis 级别覆盖它? 或者甚至可以在 machine.config 文件中设置默认行为(尽管不能 100% 确定)
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)
黄屏死机由默认的 ASP.NET HTTPHandler 提供服务。
为了拦截它,您需要在它前面添加另一个 HTTPHandler 来拦截所有未捕获的异常。
那时,您可以为错误布局做任何您想做的事情。
创建一种直接跳转到 Visual Studio 的方法会很棘手。 我可以看到它通过 COM/ActiveX 对象在 IE 中完成。
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.
如果您让它一直冒泡到 IIS,您将无法访问异常信息。 最好在 YSOD 之前捕获异常并为自己服务。
这可以在应用程序级别完成。
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.
我能想到的最简单、最懒的事情就是让这个过程发生这样的情况:
简单的 Google 搜索
提供有关如何使用外部程序操作 VS 的有用指示 例如 MSDN 上的这篇文章。
如果你想变得更时髦,那么当然还有其他方法,但我宁愿写出一个快速而肮脏的程序,并把它移开,这样我就可以做我的事情了。
不要让工具成为项目......-
Adam
The easiest, laziest thing I could think of would be to have the process happen thusly:
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
不要忘记您需要程序调试数据库 (pdb) 文件来查找源代码行号。 处于发布模式的应用程序不会具有与调试版本相同级别的信息。
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.