When debugging ASP.NET MVC app, breakpoints are not hit

后端 未结 18 1406
盖世英雄少女心
盖世英雄少女心 2020-12-25 11:45

When trying to debug a ASP.NET MVC app, the breakpoints in my controllers arent getting hit. When entering debug mode they just show an empty red circle with a warning trian

相关标签:
18条回答
  • 2020-12-25 12:35

    Things to try:

    1. Clean the Solution, then rebuild it.

    2. If that doesn't work, close the solution, delete the bin and obj folders, and rebuild.

    3. If that doesn't work, restart the IDE after doing step #2.
    4. If you're debugging an ASP.NET project hosted by IIS, make sure you're attached to the correct process (w3wp.exe).
    0 讨论(0)
  • 2020-12-25 12:36

    Some team member deleted the Debug configuration for one project (The MVC Project). Though the Solution configuration was set to "Debug / AnyCPU", if you looked in the configuration for that, the Project-Configuration for the MVC Project was set to Release, with no option for Debug, and all other projects were set as Debug appropriately.

    So I added Debug back to the project configurations (Just drop-down "Add"... uncheck the box to add to solution). And viola...

    0 讨论(0)
  • 2020-12-25 12:36

    I had a similar problem with a simple Web API project in Visual Studio 2015. I solved the problem, after reading that the easy fix was to set the Startup Project to the correct project. Since I had another Web API project in the same solution, I guessed that the project I was debugging was mixing up which index.html to debug, so I renamed that current one to index2.html. Then setting the Project properties Web tab to Specific Page and the page text: "index2.html" solved the problem.

    0 讨论(0)
  • 2020-12-25 12:38

    It might be helpful to:

    1. Close Visual Studio
    2. Stop application pool in IIS Manager
    3. Delete bin and obj folder
    4. Start appliction pool
    5. Open Visual Studio and rebuild solution
    0 讨论(0)
  • 2020-12-25 12:40

    None of these answers helped me. Some of my breakpoints were hit, and some not. But I discovered the problem in my case.

    If there is a file at the exact same virtual location with the exact same name as the URL you are trying to debug, the file will be served to the browser automatically by IIS and the breakpoint will not be hit because no MVC code actually runs.

    0 讨论(0)
  • 2020-12-25 12:40

    I have read and implemented all the suggestions above, to no avail.

    What worked for me is, i simply changed the controller action i was trying to break into to [HttpPost].

    My issue was that i was trying to debug a method decorated with a [HttpGet] attribute routing to a different view and instead of hitting my break point, it keeps routing and displaying the return view.

    Hope this helps someone!

    Happy coding.

    0 讨论(0)
提交回复
热议问题