C# 从VisualStudio调试HTTP处理程序

C# 从VisualStudio调试HTTP处理程序,c#,visual-studio-2010,httphandler,visual-studio-debugging,C#,Visual Studio 2010,Httphandler,Visual Studio Debugging,我试图在VisualStudio中调试HTTP处理程序,但断点没有被命中。有人知道如何在VisualStudio中调试HTTP处理程序吗 我正在Windows 7计算机上使用VS 2010 Premium.NET 4.0。在我的Web应用程序中,我在/HTTPHandler/TrackingHandler.cs中有一个HTTP处理程序 以下内容在我的web配置文件中: 我使用内置Web服务器在VisualStudio调试中使用任意随机页面启动Web应用程序。然后我编辑URL以指向/tx/目录,并

我试图在VisualStudio中调试HTTP处理程序,但断点没有被命中。有人知道如何在VisualStudio中调试HTTP处理程序吗

我正在Windows 7计算机上使用VS 2010 Premium.NET 4.0。在我的Web应用程序中,我在/HTTPHandler/TrackingHandler.cs中有一个HTTP处理程序

以下内容在我的web配置文件中:

我使用内置Web服务器在VisualStudio调试中使用任意随机页面启动Web应用程序。然后我编辑URL以指向/tx/目录,并在其后添加一些随机字符串。例如,我当前的URL看起来像http://localhost:53699/tx/sdfs. 我认为这应该在ProcessRequest的第一行上拉起断点,但事实并非如此

如果有任何想法,我将不胜感激

O.O

编辑:附加信息

在“项目属性”的“Web”选项卡中,我选择了“不打开页面”。等待来自外部应用程序的请求。我还得到了一个System.Web.HttpException,所以我转到Debug->Exceptions->Common Language Runtime并选中System.Web旁边的复选框

下面是我的堆栈跟踪。我的处理人似乎不明白。我是否在我的Web配置中错误地定义了它


将处理程序发布到它自己的IIS应用程序,然后将Visual Studio发布到IIS,您就可以进行调试了

如果在调试HTTP处理程序时不想或无法部署到IIS,我将配置生成后脚本以将项目发布到IIS,则可以通过将项目的启动选项设置为“不打开页面”并将Visual Studio附加到aspnet_wp.exe来调试Cassini


不要忘记以管理员身份运行Visual Studio,否则附加将无法工作。

当所有其他操作都失败时,您可以使用DebugBreak、\u DebugBreak或\u asm int 3在应用程序中生成一个。当执行此操作并安装了MSDev时,应该会出现一个对话框,询问您是否要终止或调试。这使您可以立即运行并稍后附加,并且可以在不知道附加到什么的情况下工作。

如果将进程附加到断点,则断点将被命中,例如,从选项工具->附加到进程并选择所需的进程中的w3wp.exe。

@tbroberg:我将DebugBreak放在哪里?它在ProcessRequest的第一行不起作用。我无法编译DebugBreak。我假设这只是C++,而我使用C i代替调试器。Debugger.Break;-但这不起作用。啊,C。看到了,谢谢。我在进程列表中找不到aspnet_wp.exe。我尝试在VS中使用“不打开页面”选项启动它,如编辑我的原始问题中所述。从堆栈跟踪来看,我认为它甚至没有进入我的代码。我总是以管理员身份运行VS。AttachTo加载项与VS.NET 2015不兼容
<system.webServer>
        <handlers>
            <add name="TrackingHandler" path="/tx/*" verb="*" type="ProjectNamespace.TrackingHandler" resourceType="Unspecified" preCondition="integratedMode" />
        </handlers>
  </system.webServer>
namespace ProjectNamespace
{
    public class TrackingHandler : IHttpHandler
    {
        public bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
             //Breakpoint on the very first line below
             string tracker = Path.GetFileName(context.Request.PhysicalPath);
              .......
         }
     }
}
>   System.Web.dll!System.Web.StaticFileHandler.GetFileInfo(string virtualPathWithPathInfo, string physicalPath, System.Web.HttpResponse response) + 0x1f7 bytes    
    System.Web.dll!System.Web.StaticFileHandler.ProcessRequestInternal(System.Web.HttpContext context = {System.Web.HttpContext}, string overrideVirtualPath) + 0xc7 bytes  
    System.Web.dll!System.Web.DefaultHttpHandler.BeginProcessRequest(System.Web.HttpContext context, System.AsyncCallback callback = {Method = {System.Reflection.RuntimeMethodInfo}}, object state = null) + 0x15c bytes   
    System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() + 0x2d7 bytes    
    System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step = {System.Web.HttpApplication.CallHandlerExecutionStep}, ref bool completedSynchronously = true) + 0xb9 bytes  
    System.Web.dll!System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(System.Exception error) + 0x13e bytes  
    System.Web.dll!System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext context, System.AsyncCallback cb, object extraData) + 0xf8 bytes  
    System.Web.dll!System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest wr = {Microsoft.VisualStudio.WebHost.Request}) + 0x1a2 bytes  
    System.Web.dll!System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest wr) + 0x7d bytes  
    System.Web.dll!System.Web.HttpRuntime.ProcessRequest(System.Web.HttpWorkerRequest wr) + 0x47 bytes  
    WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Request.Process() + 0x17b bytes 
    WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Microsoft.VisualStudio.WebHost.Connection conn = {System.Runtime.Remoting.Proxies.__TransparentProxy}) + 0x6c bytes 
    [Appdomain Transition]  
    WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Server.OnSocketAccept(object acceptedSocket) + 0x83 bytes   
    mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) + 0x2d bytes 
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xb0 bytes    
    mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x5a bytes 
    mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x147 bytes  
    mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x2d bytes    
    [Native to Managed Transition]