调试 ASP.NET MVC 应用程序时,未命中断点

发布于 2024-07-17 05:39:30 字数 438 浏览 6 评论 0原文

当尝试调试 ASP.NET MVC 应用程序时,我的控制器中的断点没有被命中。 进入调试模式时,它们仅显示带有警告三角形的空红色圆圈,而不是正常的完整圆圈。 这很奇怪,因为到目前为止调试工作正常,并且我的环境已经有一段时间没有进行任何配置更改了。

我已经看到这个问题并查看了我的模块视图和没有加载正确的,但是我不知道如何解决这个问题。 此外,所有相关的 pdb 文件都位于站点的 bin 文件夹中。

对于如何解决这个问题,有任何的建议吗?

干杯!

编辑:该应用程序在 IIS7 上作为本地站点运行,我正在使用 VS 2008 进行调试

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 triangle instead of the normal full circle. This is strange because debugging was working fine until now, and no configuration changes have been made in my environment for a while.

I have seen this question and had a look at my modules view and the correct ones aren't being loaded, however I'm not sure how to remedy this. Also all the relevant pdb files are in the bin folder of the site.

Any suggestions on how to fix this?

Cheers!

EDIT: The app is running as a local site on IIS7 and I'm debugging with VS 2008

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(20

伤感在游骋 2024-07-24 05:39:30

好吧,浪费了 4 个小时后,我发现将我的 Web 项目设置为启动项目解决了问题! 这肯定是一个错误......

我希望我能帮别人节省半天时间:)

Ok so after 4 hours wasted, I find that setting my web project as the startup project solves the issue! This surely must be a bug...

I hope I save someone out there half a day :)

陪你搞怪i 2024-07-24 05:39:30

更多可能性:

  • 如果您的解决方案中有客户端和服务器(假设是 WPF 和 WCF 应用程序),您应该确保选择“多个启动项目'。 [这个与您接受的答案类似,但如果您也需要运行客户端,则很有用]

  • 为项目选择了发布模式。 当在新机器上进行新的获取(正如我今天发现的那样)时,VS 似乎喜欢切换到“发布”配置文件。

Few more possibilities:

  • If you have a client and server in your solution (lets say a WPF and WCF app) you should make sure you select 'multiple startup projects'. [this one is similar to your accepted answer, but useful if you need a client running too]

  • Release mode is selected for the project. When doing a fresh get (as I discovered today) on a new machine VS seems to like to switch to 'Release' configuration profile.

薄荷梦 2024-07-24 05:39:30

某些团队成员删除了一个项目(MVC 项目)的调试配置。 尽管解决方案配置设置为“调试/AnyCPU”,但如果您查看配置,MVC 项目的项目配置设置为发布,没有调试选项,所有其他项目都相应设置为调试。

所以我将调试添加回项目配置(只需下拉“添加”...取消选中该框以添加到解决方案)。 还有中提琴...

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...

迷路的信 2024-07-24 05:39:30

我有同样的问题。 检查此处:工具->选项->

通过选择启用.Net Framework源步进进行调试修复

I had the same problem. Check here: Tools->Options->Debugging

Fix by selecting Enable .Net Framework source stepping

ζ澈沫 2024-07-24 05:39:30

要尝试的事情:

  1. 清理解决方案,然后重建它。

  2. 如果这不起作用,请关闭解决方案,删除 binobj 文件夹,然后重建。

  3. 如果这不起作用,请在执行步骤 #2 后重新启动 IDE。
  4. 如果您正在调试由 IIS 托管的 ASP.NET 项目,请确保您附加到正确的进程 (w3wp.exe)。

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).
注定孤独终老 2024-07-24 05:39:30

这些答案都没有帮助我。 我的一些断点被击中,有些则没有。 但我在我的案例中发现了问题。

如果在完全相同的虚拟位置中有一个文件与您尝试调试的 URL 具有完全相同的名称,则 IIS 将自动将该文件提供给浏览器,并且不会命中断点,因为实际上没有运行任何 MVC 代码。

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.

兲鉂ぱ嘚淚 2024-07-24 05:39:30

当我遇到这个问题时,以下方法大部分时间都对我有用:

查找项目 dll 缓存的保存位置(通常在 ASP.NET 临时文件中)。 然后关闭VS,执行IISRESET /stop(如果您使用的是IIS),删除dll缓存中的所有文件。 执行 IISRESET,启动 VS,打开项目并重建它。

The following has worked for me most of the time when I had this problem:

Find where your projects dll cache is being held (usually in ASP.NET Temprorary Files). Then close VS, do an IISRESET /stop (if you're using IIS), delete all the files in dll cache. Do an IISRESET, start VS, open your project and rebuild it.

寻找我们的幸福 2024-07-24 05:39:30

将 Visual Studio 标头发布选项更改为“调试”

Change in Visual Studio Header Release option to Debug

握住我的手 2024-07-24 05:39:30

我有同样的问题。
检查这里:
工具->选项->调试 选中

脚本复选框。
运行应用程序。

我收到安装损坏消息框,因此修复了 vs 2008,并且
现在正在工作。

I had the same problem.
Check here:
Tools->Options->Debugging

Check the script check box.
Run the application.

I got installation corrupt message box, so did a repair of vs 2008, and
its working now.

怕倦 2024-07-24 05:39:30

我今天遇到了这个问题 - 然后发现它发生的原因是:

  1. Visual Studio 2008 崩溃了,Cassini(内部开发 Web 服务器)在原始端口上运行。

  2. 当我重新打开我的项目并“启动”它时,它无法在原始端口上运行,因为旧的开发 Web 服务器仍在运行(我没有注意到)

  3. 页面浏览良好,但没有遇到断点,因为我使用的 URL 仍然指向旧的开发 Web服务器端口。

I had this problem today - then found out that it happened because:

  1. Visual Studio 2008 had crashed, leaving Cassini (the intrinsic development web server) running on the original port.

  2. When I reopened my project and "Started" it, it couldnt run on the original port because the old development web server was still running (which I didnt notice)

  3. The pages browsed fine, but no breakpoints got hit because the URL I was using was still pointing to the old development web server port.

衣神在巴黎 2024-07-24 05:39:30

清理/重建对我不起作用。
重启VS就可以了。

VS 2012、ASP.NET MVC 3、IIS Express。

Clean / rebuild didn't work for me.
Restarting VS did.

VS 2012, ASP.NET MVC 3, IIS Express.

趴在窗边数星星i 2024-07-24 05:39:30

确保您的编译框架版本与项目的编译框架版本相同。我遇到了这个问题,这是因为该项目被编译为 4.5,而 Web 配置中的编译 attrib 试图将其调试为 4.5.1。

Make sure that your compilation framework version is the same as your project's compilation framework.. I ran into this and it was because the project was being compiled as 4.5 and the compilation attrib in the web config was trying to debug it as 4.5.1.

夜雨飘雪 2024-07-24 05:39:30

这可能会有所帮助:

  1. 关闭 Visual Studio
  2. 在 IIS 管理器中停止应用程序池
  3. 删除 bin 和 obj 文件夹
  4. 启动应用程序池
  5. 打开 Visual Studio 并重建解决方案

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
北方。的韩爷 2024-07-24 05:39:30

我在 Visual Studio 2015 中的一个简单的 Web API 项目中遇到了类似的问题。在阅读简单的解决方案是将启动项目设置为正确的项目后,我解决了该问题。 由于同一解决方案中有另一个 Web API 项目,我猜测我正在调试的项目混淆了要调试的 index.html,因此我将当前项目重命名为 index2.html。 然后将项目属性 Web 选项卡设置为“特定页面”和页面文本:“index2.html”解决了问题。

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.

诗酒趁年少 2024-07-24 05:39:30

我已搁置了 TFS 中的更改,并在搁置的 cs 文件上设置了断点,该文件不再是解决方案的一部分。 当我取回我的书架后,一切都正常了。

I had Shelved my changes in TFS and had a breakpoint set on a shelved cs file that was not part of the solution anymore. Once I retrieved my Shelveset, everything worked.

七秒鱼° 2024-07-24 05:39:30

快速修复...

在调试中运行我的项目。
清理并重建解决方案 (MVC)。

重新运行 UI 项目,断点再次开始工作。

希望这会对某人有所帮助。

Quick fix...

Run my project in Debug.
Cleaned and rebuild solution (MVC).

Re run the UI project and the Breakpoints started working again.

Hope this will help someone.

半枫 2024-07-24 05:39:30

我已阅读并实施了上述所有建议,但无济于事。

对我有用的是,我只是将我试图闯入的控制器操作更改为[HttpPost]。

我的问题是,我试图调试一个用 [HttpGet] 属性装饰的方法,路由到不同的视图,而不是命中我的断点,而是继续路由并显示返回视图。

希望这对某人有帮助!

快乐编码。

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.

筱武穆 2024-07-24 05:39:30

大多数时候,您的解决方案已从调试模式更改为发布模式。

https://www.youtube.com/watch?v=Tc-EamOXAcQ

Most of time when your solution has changed into debug to Release mode.

https://www.youtube.com/watch?v=Tc-EamOXAcQ

趁微风不噪 2024-07-24 05:39:30

我发现项目属性窗口“构建”选项卡上的“优化代码”复选框也会导致出现这种情况。

也取消选中此复选框。

优化代码项目属性的“构建”选项卡上的复选框

I found that the Optimize code checkbox on the project properties window, Build tab, would also cause this to occur.

Uncheck this checkbox as well.

Optimize code checkbox on Build tab of Project properties

娇俏 2024-07-24 05:39:30

我的解决方案基本上是我的错误,因为我移动了项目文件夹。 我的解决方案是,移动文件夹后,不要使用“打开...打开网站”,然后浏览到您的网站文件夹。 不要浏览到您的解决方案 .sln 文件并使用该文件打开。 相反,请使用“打开...项目/解决方案”,然后浏览到您的 csproj 文件并打开它。 首先关闭 IIS(Express)。 重建。 它应该运行最新的副本。 .sln 每次都会把你搞乱。

My solution was basically my mistake because I had moved the project folder. My resolution was, after I moved the folder, do NOT use "Open...Open website" and then browse to your website folder. DO NOT browse to your solution .sln file and open with that. Instead, DO USE "Open...Project/Solution" then browse to your csproj file and open that. Close IIS(Express) first. Rebuild. It should run the latest copy. The .sln will mess you up every time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文