在 Visual Studio 2019 中,我啟動了我的 .NET Core 3 Wep API。它運行并接受請求。
然后,在我的 Angular UI 中,我有一個新的部分來選擇一個檔案。如果我點擊它,然后選擇一個檔案,或者在打開的對話框中點擊取消,我的 Web API 應用程式就會關閉。我試圖了解這怎么可能。我只做前端的東西。沒有進行網路呼叫。
這是我點擊的截圖。

當我點擊取消時,我的 Web API 停止。我可以在 VS 中看到我的運行按鈕再次啟用,就像它準備好再次啟動一樣。
在前端,這就是正在發生的一切:
<label style="float: left;">
<input #imageInput
type="file"
accept="image/*"
(change)="processFile(imageInput)">
</label>
<div [ngStyle]="{'background-image': 'selectedImage'}">
</div>
這是processFile()函式:
processFile(imageInput: any) {
// https://www.freecodecamp.org/news/how-to-make-image-upload-easy-with-angular-1ed14cb2773b/
console.log('in process file');
//this.selectedImage = imageInput;
}
你可以看到只有一個呼叫來記錄一些東西。在開發工具中,沒有網路呼叫或控制臺錯誤。選擇檔案(或在打開的對話框中點擊取消)如何導致我的后端服務停止?我什至不確定要檢查什么。
uj5u.com熱心網友回復:
我不知道為什么會出現此問題,但您可以在 Visual Studio 中嘗試此操作:
關閉Tools > Options > Projects and Solutions > Web Projects -> Stop debugger when browser window is closed, close browser when debugging stops以查看是否可以解決問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/364423.html
標籤:有角的 asp.net核心 asp.net-core-webapi
