Visual Studio 2013 breakpoint issue with Razor

For some reason, I cannot set a breakpoint in @functions when using Visual Studio 2013 . Here is an example:

VS2013

However, the same type of breakpoint works in Visual Studio 2012 :

VS2012

  • If you move the @functions block at the top of the razor page in VS2013 , you can set the breakpoint at @functions .

  • You cannot set a breakpoint in @functions if the block is somewhere in the HTML.

Does anyone know why? Maybe a mistake? . This is a big inconvenience if you port a web application from MVC4 or earlier, where @function blocks appear in HTML.

+7
visual-studio-2013 visual-studio-2012 razor asp.net-mvc-4
source share
4 answers

This seems like a known issue. See Error Message in MS Connect.

Description:

"After my upgrade to VS 2013, I can no longer debug javascript in MVC razor files."

http://connect.microsoft.com/VisualStudio/feedback/details/807088/unable-to-debug-javascript-from-the-vs-2013-ide-unable-to-set-breakpoint

+2
source share

I had all the same problems with "This is not a valid place for a breakpoint", and I also did not have code highlighting or intellisense on any of the Razor code. None of the solutions I could find resolved. First of all, because my problem was caused by a very stupid observation on my part, but just in case someone was here and made the same mistake, I thought I would share it.

If you have not physically created the view in Visual Studio, for example, if it was created with the NuGet package (Umbraco in my case), or if you opened an existing solution that does not belong to you ... The view may not be included in the project. You can see something like this enter image description here

Please note that the Homepage.cshtml file is located there, and I can edit, compile, display it, etc. But I could not insert a breakpoint anywhere. Right-clicking on the file and selecting "Include in Project" was a fix for me.

+2
source share

What worked for me: Exclude the file, and then Include it again. Raised breakpoints right away.

Hope this helps!

0
source share

What helped me overcome this problem was to enable the "ASP.NET" parameter in the project properties. See screenshot: Screenshot from Project Properties

-2
source share

All Articles