現象:本地運行正常,部署到 IIS 服務器後登錄跳轉報 404。
C:\Project\...) 或假設根目錄為 /?~/ (Server.MapPath) 或 Request.ApplicationPath。Default.aspx / Login.aspx,導致訪問目錄 404。web.config 中 <system.webServer><rewrite> 或 RouteConfig 規則在服務器環境不生效 (需安裝 URL Rewrite 模組、權限)。IIS_IUSRS 讀寫權限。<httpErrors existingResponse="PassThrough" /> 確保 ASP.NET 錯誤不被 IIS 攔截。C:\inetpub\logs\LogFiles\W3SVC1) 查看 sc-status=404 的 cs-uri-stem。https://localhost/... 排除防火牆/代理因素。<!-- web.config 確保路由模組運行 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule" />
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler" />
</handlers>
</system.webServer>
核心策略:**對比本地與服務器請求 URL 差異,修正虛擬目錄層級、路由規則、權限與默認文檔。**