Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
Visual Studio interprets JavaScript as C# which causes errors

Here in my code in my ASP.NET Core project I have that's causing the issue:Code in question

As Text:

<script>
/**
     * Get a setting value.
     * @param {string} name
     * @param defaultValue
     * @returns {*}
     */
    getSetting(name, defaultValue) {
        return name in this.settings ? this.settings[name] : defaultValue;
    }
</script>

The error that I'm getting for every documentation code, which is red lined is https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0103 which gets clearly identified as C# code, even though I'm writing this code in a .cshtml file <script> tag...

How do I fix this? It prevents me from compiling and executing...

I am using Visual Studio 2022 Preview 4.1 if that matters

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

.cshtml files are interpreted as Razor templates where @ is used to mark C# code in the template.

You can either escape with a second @ i.e. @@param etc or move the JS to a separate file.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!