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

135
Vistas
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 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