For some reason, I can't set a breakpoint in @functions
when using Visual Studio 2013. Here's an example:
However, the same kind of breakpoint works in Visual Studio 2012:
If you move the @functions
block up to the top of the razor page in VS2013 you can set a breakpoint in @functions
once again.
You cannot set a breakpoint in @functions
if the block is somewhere in the HTML.
Anyone know why? Maybe a bug? This is a big inconvenience if you're migrating an web app from MVC4 or earlier where @function
blocks appear in the HTML.
This seems like a known issue. See reported bug in MS Connect.
Description:
"After my upgrade to VS 2013, I am no longer able to debug javascript within MVC razor files. "
http://connect.microsoft.com/VisualStudio/feedback/details/807088/unable-to-debug-javascript-from-the-vs-2013-ide-unable-to-set-breakpoint
I had all of the same issues with "This not a valid location for a breakpoint", and I also had no code highlighting or intellisense on any of the Razor code. None of the solutions I could find resolved it. Primarily because my issue was due to a really dumb oversight on my part, but just in case anyone finds themselves here and have made the same mistake, I thought I'd share it.
If you did not physically create the view yourself in Visual Studio, like if it was created with a NuGet package (Umbraco in my case), or if you opened an existing solution that isn't yours...The view may not be included in the project. You may see something like this
Notice that the Homepage.cshtml file is in there and I can edit it, compile it, render it etc. But I could not insert a breakpoint anywhere. Right clicking on the file and Selecting "Include In Project" was the fix for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With