测试实现 IHttpHandler.ProcessRequest 的方法
所以我有一个实现 IHttpHandler.ProcessRequest 的方法。它接受 HttpContext 参数。该参数只是一个用一些 XML 填写的表单。这是我用来生成帖子上下文的 HTML:
<html>
<body>
<form name="form1" method="post" action="http://localhost:7703/api.ashx">
<textarea name="XML" id="XML" rows="25" cols="100"></textarea>
<br/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
如您所见,非常简单。这仅用于测试目的。我正在做的就是在该文本框中发布 XML,然后点击“提交”。但是,我不确定将我的 Visual Studio 项目附加到什么位置以便进行调试。我尝试将它附加到 w3wp.exe,就像我在浏览器中测试应用程序时所做的那样,但这似乎不起作用。当我在 ProcessRequest 方法旁边放置一个断点并附加时,它仍然显示“永远不会命中此断点,不会加载任何符号...”等等等等。
我如何正确测试这个?
谢谢你们。
So I have a method that implements IHttpHandler.ProcessRequest. It accepts an HttpContext parameter. This parameter is just a form that is filled out with some XML. Here is the HTML that I am using to generate the post context:
<html>
<body>
<form name="form1" method="post" action="http://localhost:7703/api.ashx">
<textarea name="XML" id="XML" rows="25" cols="100"></textarea>
<br/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
As you can see, very simple. This is just used for testing purposes. What I am doing is posting XML in that textbox, and hitting submit. However, I am not sure what to attach my visual studio project to in order to debug. I try attaching it to w3wp.exe like I do when I test the app in a browser and stuff, but that doesn't seem to be working. It still says "This breakpoint will never be hit, no symbols loaded..." blah blah blah, when I put a breakpoint next to the ProcessRequest method and attach.
How do I test this properly?
Thanks guys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在本地运行它,您应该能够从 Visual Studio 中“运行”它,并且 VS 会自动将其附加到正确的进程。
If you run this locally you should be able to "run" it from within Visual Studio and VS will automatically attach it self to the correct process.
如果我在与帖子相同的端口连接到开发服务器,它就可以工作! :)
If I attach to the development server at the same port as the post, it works! :)