Valid javascript/Razor syntax marked as syntax error - by notken_uk

Status : 

  Deferred<br /><br />
		The product team has reviewed this issue and has deferred it for consideration at a later time.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 760339 Comments
Status Closed Workarounds
Type Bug Repros 19
Opened 8/30/2012 2:34:22 AM
Access Restriction Public


When attempting to output json to a view in javascript, it's marked as being a syntax error despite being valid. If I surround with quotes or square brackets it's fine, but that's not what I need to do!

[Javascript function inside script tag]
var existing = @(Model.ToMvcHtmlStringJson());

Red-underlining of the last semi-colon, marked as syntax error, and view won't compile.

This wasn't an issue in VS 20120
Sign in to post a comment.
Posted by Sumiflow on 3/5/2014 at 9:22 AM
This still hasn't been fixed even in visual studio 2013. What's the deal?
Posted by Ken Smith on 8/20/2013 at 12:04 PM
Any update, guys? It's been a year now.

I love Visual Studio, but it's when bugs like this go unfixed for so long that I start dreaming about how cool it would be to work on an open source stack...
Posted by Sachelis on 8/1/2013 at 10:51 AM
I'm experiencing the same problem in VS2012. In my case, I can assign the ASP value to a variable and use it in the javascript.

This works:

    var proposalCount = @(Model.Proposals.Count())
    $("#ProposalsHeading").text(" (" + proposalCount + ")");

Whereas this next code displays a syntax error on the ";". Note that for me, it'll still compile and run, but the trailing ")" isn't displayed:

    $("#ProposalsHeading").text( " (" + @(Model.Proposals.Count() + ")");

Posted by PRISMAY on 7/3/2013 at 6:38 AM
Is there an update on this issue? I just installed Update 3 and this has NOT been fixed. What's the hold up? Thanks.
Posted by Mads [MSFT] on 10/25/2012 at 2:34 PM
Thank you for passing along this issue to us. At this point, we are pulling together this and other feedback as part of our planning and evaluation for the next release. We know that our customers are the most qualified people to help us learn how to make our products better, and we greatly appreciate hearing from you.
Posted by 2Mode on 10/16/2012 at 8:21 AM
I entered a StackOverflow page at:

To reproduce at the following to a razor page

    var listData = "test";
    var pagerData = "test2";
    <script type="text/javascript" >
        var ListData = @(Html.Raw(listData))
        var PagerData = @(Html.Raw(pagerData))

If you add a semi-colon at the end of the ListData line you get a javascript syntax error, without one it is on the next line. This a bug in the javascript compiler between VS2010 and VS2012.

Posted by Microsoft on 8/30/2012 at 7:26 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Microsoft Visual Studio Connect Support Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Helen [MSFT] on 8/30/2012 at 2:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(