从 ASP.NET 黄色错误页面直接链接到 VS 源代码

发布于 2024-07-05 06:09:07 字数 205 浏览 4 评论 0原文

当 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

身边 2024-07-12 06:09:07

您可能需要在页面中嵌入 ActiveX 控件才能实现类似的操作。

You would probably need to embed an ActiveX control in the page for something like that to be possible.

っ左 2024-07-12 06:09:07

就服务器而言,黄屏死机只是一个 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)

遗心遗梦遗幸福 2024-07-12 06:09:07

黄屏死机由默认的 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.

咆哮 2024-07-12 06:09:07

就服务器而言,黄屏死机只是一个 500 错误,您可以使用 web.config 的错误部分重定向到自定义屏幕。 要以相同的方式更改整个服务器,您可能可以在 iis 级别覆盖它? 或者甚至可以在 machine.config 文件中设置默认行为(尽管不能 100% 确定)

如果您让它一直冒泡到 IIS,您将无法访问异常信息。 最好在 YSOD 之前捕获异常并为自己服务。

这可以在应用程序级别完成。

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.

尹雨沫 2024-07-12 06:09:07

我能想到的最简单、最懒的事情就是让这个过程发生这样的情况:

  1. 修改黄色屏幕,这样源代码行就可以点击了。 单击时,它会提供一个带有源文件名和行号的小文本文件。
  2. PC 上的小程序与黄屏允许您下载的小文件的扩展名相关联。 该程序使用 Visual Studio 的可扩展性模型来打开源文件并转到该行。 该程序可能需要知道您的源代码在哪里。

简单的 Google 搜索
提供有关如何使用外部程序操作 VS 的有用指示 例如 MSDN 上的这篇文章

如果你想变得更时髦,那么当然还有其他方法,但我宁愿写出一个快速而肮脏的程序,并把它移开,这样我就可以做我的事情了。

不要让工具成为项目......-

Adam

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

感受沵的脚步 2024-07-12 06:09:07

不要忘记您需要程序调试数据库 (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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文