我與這條路的動作中檢索index.html文件:腳本/樣式錶鏈接從wwwroot的回報擔任404
/services/parts/{number}
從wwwroot文件夾
...
return ContentResult(html, "text/html");
在wwwroot文件夾我有這樣的結構:
wwwroot
|
---services
|
---parts
|
---1
|
---index.html
|
---2
|
---index.html
// and so on 3,4, ...
因爲我s在檢索index.file並返回它是沒有問題的,但是index.html文件中嵌入的所有鏈接/腳本無法加載,所以我得到這些鏈接的404。
然後我檢查爲什麼爲每個鏈接404:
請求的URL:URL:http://localhost:60000/services/parts/2/~/styles/vendor/bootstrap.min.css
在index.html的樣式錶鏈接:
<link rel="stylesheet" type="text/css" href="~/styles/vendor/bootstrap.min.css">
更改樣式錶鏈接:
<link rel="stylesheet" type="text/css" href="styles/vendor/bootstrap.min.css">
結果在請求的網址,沒有大的變化...
Requested url: URL:http://localhost:60000/services/parts/2/styles/vendor/bootstrap.min.css
爲什麼在asp.net核心框架嘗試從路線服務/配件/ 2,而不是從款式/供應商的文件夾中的wwwroot文件夾下的子文件夾被下載bootstrap.min.css?
我該如何解決這個問題?
太棒了!新年快樂:-) – Pascal
奇怪...它停止工作,沒有任何改變...所有CSS文件的路徑是正確的url http:// localhost:56071/styles/vendor/bootstrap.min.css我得到一個404.但是該文件正好放在wwwroot的路徑中。 – Pascal