调试 HTTP 处理程序

发布于 2024-12-23 15:35:14 字数 1518 浏览 1 评论 0原文

我在 2003 年使用 IIS 6。我创建了一个继承自 IHttpAsyncHandler 的 HTTP 处理程序 dll。该 dll 构建到 inetpub\www8080root\common\bin 目录中。它的目的是拦截所有请求。

该网站设置为监视端口8080。我在www8080root目录中创建了一个公共文件夹,并在II6中创建了一个虚拟目录来指向它。 我在公共目录中创建了一个 web.config 文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
    <compilation debug="true" defaultLanguage="c#" />
    <httpHandlers>
        <add verb="*" path="*"
            type="x2Handler.x2Handler, x2Handler" />
    </httpHandlers>
</system.web>
</configuration>

当我访问 http://localhost:8080/common/ index.html HTTP 处理程序导致 w3wp.exe 崩溃,当我查看事件日志时,我可以看到处理程序中导致崩溃的错误。当我在 VS 2005 中设置断点时,代码没有被命中。

为了调试,我需要以某种方式附加到在 IIS 下运行的进程,但一旦处理请求,它就会崩溃。

如何在 IIS 下调试 HTTP Handler dll?我看不到要附加的 aspnet_wp.exe 进程,如下所述:C#,调试 HTTPHandler

编辑: 通过添加 Debugger.Break(),我现在收到消息“w3wp.exe 已触发断点”,它允许我选择调试环境,但它加载时没有

No symbols are loaded for any call stack frame. The source code cannot be displayed.

我设置的符号“工具”->“选项”->“调试”->“调试”。仅启用我的代码 我将路径设置为从中加载符号的 common/bin 位置。任何手动设置的断点仍然显示:

The breakpoint will not currently be hit. No symbols have been loaded for this document.

编辑: 当它加载时,它似乎正在寻找 ntdll.pdb 的符号。即使我手动加载 httpHandler 的符号文件也没有什么区别。
不过,代码肯定正在执行。

I am using IIS 6 on 2003. I have created a HTTP handler dll that inherits from IHttpAsyncHandler. The dll builds into the inetpub\www8080root\common\bin directory. It is meant to intercept all requests.

The web site is set to monitor port 8080. I have created a common folder in the www8080root directory and have created a virtual directory in II6 to point to it.
I created a web.config file in the common directory

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
    <compilation debug="true" defaultLanguage="c#" />
    <httpHandlers>
        <add verb="*" path="*"
            type="x2Handler.x2Handler, x2Handler" />
    </httpHandlers>
</system.web>
</configuration>

When I access http://localhost:8080/common/index.html the HTTP handler causes a crash of w3wp.exe, when I look in the event logs I can see the error within the handler that caused the crash. When I set a breakpoint within VS 2005 the code it doesn't get hit.

In order to debug I need to somehow attach to the process when it is running under IIS but as soon as it processes a request, it crashes.

How do I debug a HTTP Handler dll under IIS? I can't see a aspnet_wp.exe process to attach to as described here: C#, Debugging an HTTPHandler

EDIT:
By adding Debugger.Break() I now receive the message "w3wp.exe has triggered a breakpoint" and it allows me to select a debug environment, but it loads without symbols

No symbols are loaded for any call stack frame. The source code cannot be displayed.

I set Tools->Options->Debugging->Enable Just My Code
I set the path to the common/bin location to load symbols from. Any manually set breakpoints still display:

The breakpoint will not currently be hit. No symbols have been loaded for this document.

EDIT:
When it loads it appears to be looking for the symbols of ntdll.pdb. Even if I manually load the symbol file for the httpHandler it makes no difference.
The code is definitely executing though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

情深缘浅 2024-12-30 15:35:14

在异常发生之前添加几行Debugger.Break()。这应该会弹出一个窗口,要求附加调试器。

Add Debugger.Break() a few lines before the exception occurs. This should give you a popup asking to attach a debugger.

旧城烟雨 2024-12-30 15:35:14

问题是 .Net 的安装早于 IIS 版本。我注意到“编辑配置”按钮被禁用,并发现此网站 http://www.warfiblog。 com/edit-configuration-disabled
按照说明进行操作:

You will need to go to Start -> Microsoft Visual Studio 2005 -> Visual Studio Tools -> Visual Studio 2005 Command Prompt. On the prompt write down this command:
aspnet_regiis -r
The above command will register dot net with IIS and now the button will also be enabled.

这样做解决了调试问题!

The problem was that .Net had been installed prior to the version IIS. I had noticed the "Edit configuration" button was disabled and found this site http://www.warfiblog.com/edit-configuration-disabled.
Following the instructions:

You will need to go to Start -> Microsoft Visual Studio 2005 -> Visual Studio Tools -> Visual Studio 2005 Command Prompt. On the prompt write down this command:
aspnet_regiis -r
The above command will register dot net with IIS and now the button will also be enabled.

In doing that it fixed the debugging issue!

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