當我加載 Visual Studio 2022 時,它會在啟動時簡短地顯示“(無回應)”。
然后它將繼續作業。然后,我將使用 Internet Explorer 加載該專案,并顯示“嗯……無法訪問此頁面”。localhost 拒絕連接。
然后我在 Chrome 和 Microsoft Edge 上重試,頁面加載但影像沒有。
這不僅僅是一個特定專案的問題。在所有專案上都是一樣的。
應用設定.json
`{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime":
"Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection":
"Server=.;Database=
HondaDealership;Trusted_Connection=True"
}
}`
啟動設定.json
`{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5001",
"sslPort": 44324
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"HondaDealership": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl":
"https://localhost:5001;http://localhost:5000"
}
}
}`
我嘗試過的事情:
- 更改了應用網址,
- 更改了 sslPort,
- 卸載并重新安裝iis 10.0 express,
- 洗掉 .vs 檔案夾,
- 我是我電腦的管理員,
- 我重新啟動了我的電腦。
再次值得注意的是,這個問題發生在所有專案和所有瀏覽器上。
應該加載影像的 HTML
`<div class="text-center">
<h1 class="display-4">
Seans Honda Dealership</h1>
</div>
<div class="row">
<div id="image1" class="flex-column">
<a href="/Crx">
<img
src="C:\Users\user\source\repos
\HondaDealership\HondaDealer
ship\Images\Crx.jfif"
class="rounded"
alt="..."width="350"
height="225">
</a>
</div>
<div id="image2" class="flex-column">
<a href="/Eg6">
<img
src="C:\Users\user\source\repos\
HondaDealership\HondaDealership\
Images\Eg6.jfif"
class="rounded"
alt="..." width="350"
height="225">
</a>
</div>
<div id="image3" class="flex-column">
<a href="/Integra">
<img src="C:\Users\user\source\repos\
HondaDealership\HondaDealership\
Images\Integra.jfif"
class="rounded"
alt="..."width="350"
height="225">
</a>
</div>
</div>`
這是我右鍵單擊影像并在 Microsoft Edge 中進行檢查時出現的錯誤。
localhost/:129
Not allowed to load local resource:
file:///C:/Users/user/source/repos/
HondaDealership/HondaDealership/Images
/Crx.jfif
uj5u.com熱心網友回復:
您在 Edge 中收到錯誤,因為它是基于 Chromium 構建的。出于安全考慮,Chromium 不允許在您訪問網站時加載本地資源。從技術上講,localhost 只是瀏覽器的另一個網站。因此,就它而言,這與您在 stackoverflow.com 上并嘗試從本地計算機加載檔案沒有什么不同。
您需要使您的影像源路徑相對于您網站的根目錄,并將影像檔案放在匹配的位置。所以你應該有一個名為的目錄images,然后路徑將是localhost:129/images/Crx.jfif.
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/495102.html
