Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7886953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:27:13+00:00 2026-06-03T05:27:13+00:00

I recently started building my views in order to improve the quality and maintainability

  • 0

I recently started building my views in order to improve the quality and maintainability of my code after I switched to test-driven development too.

This helped a lot, and the compiler identified a few flaws in my views in terms of variables that had been renamed, or other things like that.

Now however, I am seeing some false positives when I build my solution. Here’s an example of some code that worked just fine before at runtime, but now won’t compile:

<script type="text/javascript">
var url = null;

@{
    Html.Raw("url = 'doesnt work';");
}

url = "@Url.Action("DoesNotWorkEither")";

</script>

Remember that this actually runs when I execute it on the server without building the views first!

Errors received

  • Invalid character at the code @{

  • Expected ‘;’ at the code url = "@Url.Action("DoesNotWorkEither")";

How can I solve these errors?

Update 1

It should be noted that ignoring this error is not an option for me. You see, it can’t even build (because I enabled building of views). This means that it will fail to build on my build server too, where I have gated check-ins (which do no allow the checkin to be submitted before it has been built and tests have been run).

Update 2

As was explained to me in a comment to an answer, this is apparently just a Visual Studio parser error which can be ignored. The build server will in fact build the views too and tell you if there’s a concrete error in the view, but will ignore the false positives.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:27:14+00:00Added an answer on June 3, 2026 at 5:27 am

    Those errors come from Visual Studio’s Javascript parser, which doesn’t know about Razor.
    They have nothing to do with the build system.

    You can safely ignore them.

    You can hide the Razor code from the Javascript parser using comments and string literals, like this: (untested)

    <script type="text/javascript">
    var url = null;
    
    /*@{ 
        Html.Raw(" *"+"/ url = 'doesnt work'; /*");
    } */
    
    url = '@Url.Action("DoesNotWorkEither")';
    
    </script>
    

    A better workaround would be to create extension methods that emit <script> tags with the data you need, then don’t call Razor at all in <script>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently started building a bookmarklet that displays the EXIF data of any image
I recently started looking into building web applications using .NET MVC and I stumbled
I have recently started programming in PHP. I am building a cart in PHP.
I recently started using lcov to visualize my code coverage. It's a great tool.
I recently started with the 'Agile web development with Rails' book by pragmatic programmers
Recently I started doing a C++ project, and started it using the internal building
I have started using django very recently . I am building a service with
Have recently started working with Sitecore 6.2. Is there a way to preserve code
I recently started a new RoR project, and copied some of my old code
I have recently started playing around with iOS development and have got most of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.