首頁  >  文章  >  php教程  >  IIS7報500.23錯誤的原因分析及解決方法

IIS7報500.23錯誤的原因分析及解決方法

高洛峰
高洛峰原創
2017-01-06 16:21:391691瀏覽

 背景:今天公司終端上有一個功能打開異常,報500錯誤,我用Fiddler找到鏈接,然後在IE裡打開,報500.23錯誤:檢測到在集成的託管管道模式下不適用的ASP.NET設定。後台是一個IIS7和tomcat7整合的環境,這裡記錄一下。

HTTP 錯誤 500.23 - Internal Server Error

偵測到在整合的託管管道模式下不適用的 ASP.NET 設定。

IIS7報500.23錯誤的原因分析及解決方法

為什麼會出現以上錯誤?

在IIS7的應用程式集區有兩種模式,一種是“整合模式”,一種是“經典模式”。

經典模式則是我們以前習慣的IIS 6 的方式。

如果使用整合模式,那麼對自訂的httpModules 和 httpHandlers 就要修改設定文件,需要將他們轉移到節裡去。

兩種解決方法:

第一種方法、配置應用程式集區

在IIS7上配置應用程式池,並且將程式池的模式改為“經典”,之後一切正常。如圖:

IIS7報500.23錯誤的原因分析及解決方法

用了IIS7.x,但實際上只發揮了6的功能,另外,在一些ASP.NET MVC程序中的效果也不好,所以,我們嘗試以下解決方法:

第二種方法、修改web.config設定檔:

註:web.config路徑C:inetpubwwwrootweb.config

例如原先設定(你的環境中可能沒有httpModules,httpHandlers節點)

<system.web>
............
<httpModules>
<add name="MyModule"type="MyApp.MyModule" />
</httpModules>
<httpHandlers>
<add path="*.myh"verb="GET"type="MyApp.MyHandler" />
</httpHandlers>
</system.web>

在IIS7應用程式池為「整合模式」時,改為:

<system.web>
...........
</system.web>
<system.webServer>
<modules>
<add name="MyModule"type="MyApp.MyModule" /> 
</modules>
<handlers>
<add name="MyHandler"path="*.myh"verb="GET"type="MyApp.MyHandler"preCondition="integratedMode" />
</handlers>
</system.webServer>

(如果你的web.config沒有httpModules,httpHandlers節點,則直接在節點system.webServer中新增:

<validation validateIntegratedModeConfiguration="false" />

禁止驗證整合模式,來避免錯誤。

IIS Log的位置
IIS 6.0的Log日誌儲存在:
c:windowssystem32logfiles

IIS 7 Log儲存在:
%SystemDrive%inetpublogsLogFiles

%SystemDrive%inetpublogsLogFiles

.

IIS 6, 7的日誌寫入按不同站點寫入不同的資料夾, 位置資料夾的格式都是"w3svc{siteId}".

IIS6裡, 查看站點ID的方式是透過IIS 查看站點ID log的資料夾的名字來決定Site ID.


IIS7中, 在IIS管理器中的advanced settings中, General裡的ID就是Site ID, 然後你需要透過這個ID來定位LogFiles資料夾中哪一個文件夾屬於你要查看的網站.

Intergrated和Classic的區別

IIS7的Application Pools有兩種mode,一種是Integrated,一種是classic。就要修改設定檔了,需要將他們轉移到節裡去。 modules和handlers從下的裡讀取,以前的下的配置節會被忽略,如果設定禁止驗證(disabledvalidation ),是不會產生錯誤的。

IIS7.0 Classic mode: 與 以上情況是相反的,會被忽略。

Classic vs Integrated
Classic mode (theonly 組成and an ISAPI filter(aspnet_filter.dll).IIS just treats Asp.net as an external plugin implemented in ISAPI and workswith it like a black box (and only when it's needs to give out the request toASP mNET). In needs to give out the request toASP.NET. Asp.net is not much different from PHP or other technologies for IIS.


經典模式是IIS6.0以及以下版本的唯一工作模式(只工作在ISAPI EXTENSION,ISAPI FILTERS下)。在此種模式下asp.net只是一個分別實作了ISAPIEXTENSION和ISAPI FILTER的插件(aspnet_isapi.dll,aspnet_filter.dll),IIs的工作只是將特定的請求轉發給Asp.net,與PHP等等寄宿在IIS中的插件別無二致。

Integrated mode,on the other hand, is a new mode in IIS7 where IIS pipeline is tightlyintegrated (i.e. is just the same) as Asp.net request pipeline. ASP.NET cansee every request it wate and ASPman al. ASP.NET isno longer treated as an external plugin. It's completely blended and integratedin IIS. In this mode, Asp.net HttpModules basically have nearly as much poweras an ISAPI filter wave basically have nearly as much poweras an ISAPI filter wave sperpiesm. extension could have. In this mode, Asp.netis basically a part of IIS.

然而在集成模式裡,IIS的管道與Asp.net的請求管道是緊密整合的,Asp.net可以完全控制,訪問整個請求管道。 Asp.net不在作為一個外部插件,而是完全整合在IIS中。在這個模式下,Asp.net HttpModules與ISAPI Filter擁有等同的控制權,Asp.net HttpHandlers與ISAPI Extension擁有等同控制權,換而言之Asp.net已經是IIS的一部分了。

如果要兼顧IIS6及IIS7,可在web.config中同時保留httpHandlers(for IIS6)及handlers(for IIS7)裡的相同定義,但記得要加上,不然IIS7會因為定義重覆出現而發生錯誤。

更多IIS7報500.23錯誤的原因分析及解決方法相關文章請關注PHP中文網!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn