我有一个现有的asp.net网站。当我(F5)调试它的工作原理。但是,我正在为该网站开发一个新的IHttpHandler。只要我将<system.webServer><handler></handler></system.webServer>
部分添加到web.config,visual studio就会拒绝使用错误进行F5调试:
无法在Web服务器上启动调试。网络服务器不能 找到所需的资源。
使用处理程序,如果我附加到进程,那么我可以成功附加到进程(并且使用System.Diagnostics.Debugger.Break();
行我可以单步执行处理程序的代码)。我还将我的处理程序添加到另一个网站,并能够重现此问题。
我的环境:.NET 4.0,Visual Studio 2012,在Windows 7上以集成模式使用本地IIS。
在尝试清理要粘贴的代码时,我最终评论了除了锅炉板之外的处理程序中的所有内容,问题仍然存在。以下是代码段:
处理程序类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MySvc
{
public class MyServiceHandler : IHttpHandler
{
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
//#if DEBUG
// System.Diagnostics.Debugger.Break();
//#endif
}
}
}
和web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<clear/>
<add key="A1" value="sanitized"/>
<add key="A2" value="sanitized"/>
</appSettings>
<connectionStrings>
<clear/>
<add name="MyDatabase" connectionString="sanitized"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600"/>
<sessionState mode="SQLServer" cookieless="false" timeout="5" allowCustomSqlDatabase="true" cookieName="My.Session"
sqlConnectionString="sanitized" />
<machineKey
validationKey="sanitized"
decryptionKey="sanitized"
validation="sanitized" decryption="sanitized" />
</system.web>
<system.webServer>
<handlers>
<clear />
<add name="MyHandler" path="*.bwsvc" verb="*" type="MySvc.MyServiceHandler, MySvc" />
</handlers>
</system.webServer>
</configuration>
我已经阅读了The Web Server Could Not Find the Requested Resource和其他许多同样的文章。似乎没有一个适用于这种情况,没有提到处理程序造成问题。
我在处理程序中遗漏了某些内容,或者这是Visual Studio不支持的内容还是其他问题?
答案 0 :(得分:0)
我发现了问题。事实证明,<clear />
部分中的<handlers>
导致了问题。一旦删除该行,调试器就会再次运行(以及许多其他事情)。
由于我的应用程序池处于集成管道模式,因此处理程序部分实际上继承了服务器设置,这些设置指定处理诸如* .aspx之类的核心事物等等,因此清楚地表明IIS不知道是什么在我的应用程序中使用任何。