Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

229
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda