Asp.net

為什麼 IIS Express 使用 <system.web> 而不是 <system.webServer>?

  • March 4, 2012

使用 Cassini 但切換到 IIS Express。我最初的想法是我可以刪除&lt;system.web&gt;除以下內容之外的所有內容:

&lt;authentication mode="Forms"&gt;
 &lt;forms loginUrl="/" /&gt;
&lt;/authentication&gt;

我以前customErrors的設置是這樣的:

&lt;customErrors mode="On" defaultRedirect="/ServerError"&gt;
 &lt;error statusCode="404" redirect="/NotFound" /&gt;
&lt;/customErrors&gt;

customErrors當我切換到 IISExpress 時,我刪除了這個元素。現在 404 不再重定向到我漂亮的“未找到”頁面。

用於我的網站的 AppPoolClr4IntegratedAppPool讓我知道它沒有使用 Classic。

為什麼 IISExpress 如此依賴system.web而 IIS 7.5 使用system.webServer

好吧,我嘗試了一些不同的方法:

  • 更改existingResponsePassThroughhere所述

&lt;httpErrors errorMode="Custom" existingResponse="Replace"&gt;

沒有!

  • 設置TrySkipIisCustomErrors=false如評論中所述

請注意!

我最終通過簡單地將其更改existingResponseReplace.

  • 誰知道!

這是system.webServer現在的樣子:

&lt;httpErrors errorMode="Custom" existingResponse="Replace"&gt;
       &lt;remove statusCode="404" subStatusCode="-1" /&gt;
       &lt;error statusCode="404" path="/NotFound" responseMode="ExecuteURL" /&gt;
       &lt;remove statusCode="500" subStatusCode="-1" /&gt;
       &lt;error statusCode="500" path="/ServerError" responseMode="ExecuteURL" /&gt;
   &lt;/httpErrors&gt;

為什麼這個解決方案沒有任何意義

Replace - 此值使自定義錯誤模組始終將錯誤資訊替換為自定義錯誤模組生成的文本。如果現有響應設置為“替換”,則由 Asp.Net/WCF 生成的錯誤/異常將被 IIS7 錯誤替換。

http://blogs.iis.net/ksingla/archive/2008/02/18/what-to-expect-from-iis7-custom-error-module.aspx

引用自:https://stackoverflow.com/questions/9542882