【发布时间】:2012-12-19 01:16:56
【问题描述】:
我有一个可用的现有 asp.net 网站。当我(F5)调试它工作。但是,我正在为该站点开发一个新的 IHttpHandler。一旦我将<system.webServer><handler></handler></system.webServer> 部分添加到 web.config 视觉工作室拒绝 F5 调试并出现错误:
无法在 Web 服务器上开始调试。网络服务器无法 找到请求的资源。
有了处理程序,如果我附加到进程,那么我可以成功附加到进程(并且使用System.Diagnostics.Debugger.Break(); 行,我可以单步执行处理程序的代码)。我还将我的处理程序添加到另一个网站,并且能够重现此问题。
我的环境:.NET 4.0,Visual Studio 2012,在 Windows 7 上以集成模式使用本地 IIS。
在尝试清理要粘贴到此处的代码时,我最终注释掉了处理程序中除样板之外的所有内容,问题仍然存在。这是sn-ps的代码:
处理程序类:
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 不支持的内容还是其他问题?
【问题讨论】:
标签: asp.net visual-studio iis visual-studio-debugging