user3953989
user3953989

Reputation: 1929

VS 2012 can't set breakpoints in Razor

When trying to set a breakpoint in a razor view I get the message "This is not a valid location for a breakpoint".

Breakpoints work in JS and everywhere else they're supposed to. Intellisense and auto-complete also work in Razor.

Using - VS 2012 Update 4 - .Net Framework 4.5.1 - MVC 5.1

Sample Code

<div>
@{ 
var testString = string.Empty;
}
</div>

Upvotes: 2

Views: 2127

Answers (3)

user6397794
user6397794

Reputation: 1

I got the same, and I resolved it as to restart the Visual studio, What i think this happens when you did changes with name of your view respectively with controller and scaffolding needs to be rerun again.so after restart the system it automatically give me the changes.

Upvotes: 0

user3953989
user3953989

Reputation: 1929

Here's is another SO problem that describes the issue I'm having and downloading the update from MS fixed it.

This is not a valid location for a breakpoint

Upvotes: 1

Brian S
Brian S

Reputation: 3234

Are you sure it's breakable code? Sometimes VS is "smart" and won't let you set a breakpoint if there is nothing there to break on.

Have you tried a larger block of code? Define the variable, assign a different value, do another op on it. Then set the breakpoint somewhere at the end or the middle.

Upvotes: 0

Related Questions