Cannot put breakpoint in an ASP.NET MVC view when running in IIS7

∥☆過路亽.° 提交于 2019-12-13 14:13:42

问题


I'm forced to use IIS7 because Casini is only x86 and we are running with x64 ELMAH.

Something I've noticed since I've switched is that I cannot set breakpoints in ASP.NET MVC views anymore. I'm not totally sure it's because of IIS7, is it? Does it happen to you as well?

The Visual Studio (2008) project is configured to use the local IIS7. I normally run the project by pressing F5, which actually doesn't run anything. It compiles the code and attaches itself to the corresponding IIS7 process.

The limitation of breakpoints is very hard into my environment now. If I right click a piece of code in a view there's a "Breakpoint" sub-menu, like before, with the Insert Breakpoint. But when I try to insert a breakpoint I get a blue message at the bottom of Visual Studio saying:

This is not a valid location for a breakpoint.

and no breakpoint is set. Setting breakpoints in the compiled code, like the controller presents no problem.

Is there any way to solve put a breakpoint in the view?


回答1:


You need to make sure you are breaking on something that is actually server side!

You obviously won't be able to break on:

<h2>Title<h2>

And perhaps surprisingly, you can't break on:

@SomeCode here

But you can break on:

@{
SomeCodeHere
}



回答2:


You can try attaching the process (Ctrl+Alt+P) to w3wp.exe and running it from there. If there are more than one w3wp.exe process running, consider using the tips from InfoPath MSDN blog.

That said, being "forced to use IIS7" over Cassini is like being forced to choose ice cream over raw sewage.




回答3:


Try running VS as the administrator, I ran into this problem trying to attach to the IIS7 w3wp.exe. I started mine as admin and has worked just fine.




回答4:


I had the same issue then I installed ASP.NET 5 RC1 Update 1, things got worst.

I solved the problem deleting the ComponentModelCache folder out of the %appdatalocal%/Microsoft/VisualStudio/14.0 folder.




回答5:


Can you set break points anywhere else in your code?

I've never personally set a break point in one of my views, have you tried setting the break point in the controller on the line which returns the view and then tried stepping into the view from there?

What are your trying to debug in your view? It should be kept clean and simple with no logic. That is why I've never needed to debug one.




回答6:


Enable line numbers for HTML here

Tool -> Options -> Text Editor -> HTML -> General


来源:https://stackoverflow.com/questions/1354764/cannot-put-breakpoint-in-an-asp-net-mvc-view-when-running-in-iis7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!