Reputation: 1150
I seem to be having an issue with using razor syntax within a javascript block. The following compiles, however, I'm getting a syntax error warning.
An example of when this happens:
@section scripts{
<script type="text/javascript">
var rating = @Model.Rating;
</script>
}
Upvotes: 1
Views: 550
Reputation: 888203
That's a false positive from the editor, which doesn't recognize Razor in JS.
Ignore it.
However, if you use this approach for textual data, make sure to Javascript-escape it, or ou will get runtime JS errors & XSS vulnerabilities.
Upvotes: 3