Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

230
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda