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

128
Visualizações
JavaScript required within RCL is not being referenced properly

I figured this should be a no-brainer but It's caused me hours of headaches already. I have a simple Razor Class Library (RCL) including a page containing some JavaScript.

@page
@*...*@
<h1>Test Page</h1>

@section Scripts {
    <script type="text/javascript" src="~/lib/somejs.js"></script>
    <script type="text/javascript">
        console.log("log something"); // works
        let something = new SomeJS("hello World");
    </script>
}

I also have a _Layout.cshtml containing @RenderSection("scripts", required: false) to allow the conditional include of the script-tag.

The given script is included, but despite the reference to ~/lib/somejs.js there is the following error occurring:

 https://localhost:44385/lib/somejs.js net::ERR_ABORTED 404

The required file is inside the RCL's wwwroot/lib folder. It seems to me that the given path is wrong as it expects the files at non-existent folder inside the actual web project rather than the RCL.

How can i resolve the reference correctly from within the RCL? Ideally, the project using it does not have to bother about including them manually.

EDIT: Even inserting the hardcoded path suggested by Visual Studio does not resolve the issue, e.g. src="../../wwwroot/lib/some.js".

about 4 years ago · Juan Pablo Isaza
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