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

135
Visualizações
Visual Studio Code doesn't add CSS Stylesheets and JS-Files to HTML code

I migrated my project from Visual Studio Enterprise to Visual Studio Code and now my CSS and JS-Files are not being embedded in the HTML-File anymore. There are no error-messages. I think the problem is, that VS sees the links as webpages on my website and searches for them and doesn't find them. I come to this conclusion because of the messages in the debug console.

My code looks like this:

@model LoginModel;
@{
    ViewData["Title"] = "Home Page";
 }
<head>
    <link   rel="stylesheet" href="../wwwroot/css/Home.css"
      type="text/css" />
    <link rel="stylesheet" href="../wwwroot/css/overview.css"
       type="text/css" />

</head>
<body>
      **more HTML code here **
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="${workspaceFolder}/NXM_Web_Client/wwwroot/js/login.js"></script>

The Debug console states that:

info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1] Request starting HTTP/1.1 GET http://localhost:5000/wwwroot/css/Home.css
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2] Request finished in 21.0984ms 404 info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1] Request starting HTTP/1.1 GET http://localhost:5000/${workspaceFolder}/NXM_Web_Client/wwwroot/js/login.js
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2] Request finished in 0.2092ms 404

The same message comes for all CSS and JS files. I allready tried marking the files as static, this didn't work.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Make sure that your files are in same folder where you have saved your main html file.Just tell me after trying did it worked.

about 4 years ago · Juan Pablo Isaza Relatório

0

While ../ in a URL means "Go to the parent segment of the path", you can't go above the server root.

wwwroot is the root.

You are trying to go from / to a level above / (which is impossible) and then back into / which leaves you in /wwwroot.

Don't do that.

Either use a relative path which doesn't go past the root (css/Home.css) or use an absolute path which starts at the root (/css/Home.css).

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