我正在嘗試將 ASP.NET Core Web API 部署到 Windows Server 中的 IIS。我首先按照本教程安裝 IIS 并部署 API,然后按照本教程配置 CORS 策略。
我正在嘗試從托管在同一服務器中的 React 網頁中獲取資料,并在服務器本身的 Edge 中打開它。React 作業正常,整個事情都在我自己的 PC 上進行了測驗,所以我猜問題一定是一些 IIS 配置。
配置 CORS 后,我停止在 React 中收到 CORS 錯誤,所以我想我做得對,但現在我收到 503 錯誤“應用程式關閉”。我嘗試(不成功)設定日志檔案。這是我的web.config。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
<cors enabled="true" failUnlistedOrigins="true">
<add origin="http://localhost">
<allowHeaders allowAllRequestedHeaders="true">
</allowHeaders>
<allowMethods>
<add method="GET" />
<add method="POST" />
</allowMethods>
</add>
</cors>
<defaultDocument>
<files>
<add value="MyExe.exe" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
該服務器是全新安裝的 Windows Server 2022。
uj5u.com熱心網友回復:
您可以嘗試打開Windows 事件查看器,嘗試查找有關IIS的錯誤,點擊查看錯誤詳情,或許對您有所幫助。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/481165.html
