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

127
Views
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
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!