IIS7報(bào)500.23錯(cuò)誤的原因分析及解決方法
背景:今天公司終端上有一個(gè)功能打開異常,報(bào)500錯(cuò)誤,我用Fiddler找到鏈接,然后在IE里打開,報(bào)500.23錯(cuò)誤:檢測到在集成的托管管道模式下不適用的ASP.NET設(shè)置。后臺(tái)是一個(gè)IIS7和tomcat7集成的環(huán)境,此處記錄一下。
HTTP 錯(cuò)誤 500.23 - Internal Server Error
檢測到在集成的托管管道模式下不適用的 ASP.NET 設(shè)置。

為什么會(huì)出現(xiàn)以上錯(cuò)誤?
在IIS7的應(yīng)用程序池有兩種模式,一種是“集成模式”,一種是“經(jīng)典模式”。
經(jīng)典模式則是我們以前習(xí)慣的IIS 6 的方式。
如果使用集成模式,那么對(duì)自定義的httpModules 和 httpHandlers 就要修改配置文件,需要將他們轉(zhuǎn)移到<modules>和<hanlders>節(jié)里去。
兩種解決方法:
第一種方法、配置應(yīng)用程序池
在IIS7上配置應(yīng)用程序池,并且將程序池的模式改為“經(jīng)典”,之后一切正常。如圖:

用了IIS7.x,但實(shí)際只發(fā)揮了6的功能,另外,在一些ASP.NET MVC程序中的效果也不好,所以,我們嘗試以下解決方法:
第二種方法、修改web.config配置文件:
注: web.config路徑C:\inetpub\wwwroot\web.config
例如原先設(shè)置(你的環(huán)境中可能沒有httpModules,httpHandlers節(jié)點(diǎn))
<system.web>
............
<httpModules>
<add name="MyModule"type="MyApp.MyModule" />
</httpModules>
<httpHandlers>
<add path="*.myh"verb="GET"type="MyApp.MyHandler" />
</httpHandlers>
</system.web>
在IIS7應(yīng)用程序池為“集成模式”時(shí),改為:
<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節(jié)點(diǎn),則直接在節(jié)點(diǎn)system.webServer中添加:
<validation validateIntegratedModeConfiguration="false" />
禁止驗(yàn)證集成模式,來避免錯(cuò)誤。
IIS Log的位置
IIS 6.0的Log日志存儲(chǔ)在:
c:\windows\system32\logfiles\
IIS 7 Log存儲(chǔ)在:
%SystemDrive%\inetpub\logs\LogFiles
經(jīng)過我的測試, IIS日志是即時(shí)寫入的, 不需要IIS reset.
IIS 6, 7的日志寫入按不同站點(diǎn)寫入不同的文件夾, 位置文件夾的格式都是"w3svc{siteId}".
IIS6里, 查看站點(diǎn)ID的方式是通過IIS log的文件夾的名字來確定Site ID.
IIS7中, 在IIS管理器中的advanced settings中, General里的ID就是Site ID, 然后你需要通過這個(gè)ID來定位LogFiles文件夾中哪一個(gè)文件夾屬于你要查看的站點(diǎn).
Intergrated和Classic的區(qū)別
IIS7的Application Pools有兩種mode,一種是Integrated,一種是classic。如果使用Integrated模式,那么對(duì)自定義的httpModules和httpHandlers就要修改配置文件了,需要將他們轉(zhuǎn)移到<modules>和<hanlders>節(jié)里去。
IIS7的兩種模式和IIS6有什么區(qū)別?
IIS7.0 Integrated mode:asp.net 的modules和handlers從<system.webServer>下的<modules> 和<handlers>里讀取,以前的<system.web>下的<httpModules> 和<httpHandlers>配置節(jié)會(huì)被忽略,如果設(shè)置禁止驗(yàn)證(disabledvalidation),是不會(huì)產(chǎn)生錯(cuò)誤的。
IIS7.0 Classic mode: 與 以上情況是相反的,<modules>和<handlers>會(huì)被忽略。
Classic vs Integrated
Classic mode (theonly mode in IIS6 and below) is a mode where IIS only works with ISAPIextensions and ISAPI filters directly. In fact, in this mode, Asp.net is justan ISAPI extension (aspnet_isapi.dll) 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.NET). In this mode, Asp.net is not much different from PHP or other technologies for IIS.
經(jīng)典模式是IIS6.0以及以下版本的唯一工作模式(只工作在ISAPI EXTENSION,ISAPI FILTERS下)。在此種模式下asp.net只是一個(gè)分別實(shí)現(xiàn)了ISAPIEXTENSION和ISAPI FILTER的插件(aspnet_isapi.dll,aspnet_filter.dll),IIs的工作只是將特定的請(qǐng)求轉(zhuǎn)發(fā)給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 wants to and manipulate things along the way. 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 would have had and Asp.net HttpHandlers can have nearlyequivalent capability as an ISAPI extension could have. In this mode, Asp.netis basically a part of IIS.
然而在集成模式里,IIS的管道與Asp.net的請(qǐng)求管道是緊密集成 的,Asp.net可以完全控制,訪問整個(gè)請(qǐng)求管道。Asp.net不在作為一個(gè)外部插件,而是完全集成在IIS中。在此模式下,Asp.net HttpModules與ISAPI Filter擁有等同的控制權(quán),Asp.net HttpHandlers與ISAPI Extension擁有等同控制權(quán),換而言之Asp.net已經(jīng)是IIS的一部分了。
如 果要兼顧IIS6及IIS7,可在web.config中同時(shí)保留httpHandlers(for IIS6)及handlers(for IIS7)里的相同定義,但記得要加上<validation validateIntegratedModeConfiguration="false"/>,不然IIS7會(huì)因?yàn)槎x重覆出現(xiàn)而發(fā)生錯(cuò)誤。
- IIS7.0 運(yùn)行ASP 500錯(cuò)誤 解決方法
- WIN2008系統(tǒng)安裝IIS7配過ASP后打開ASP網(wǎng)站為500錯(cuò)誤的解決辦法
- IIS7.5顯示ASP的詳細(xì)錯(cuò)誤信息"500 – 內(nèi)部服務(wù)器錯(cuò)誤解決"
- IIS7使用.NET Framework v4.0運(yùn)行庫報(bào)500錯(cuò)誤的解決辦法
- Win7 IIS7.5運(yùn)行ASP時(shí)出現(xiàn)500錯(cuò)誤的解決辦法
- IIS7.5中調(diào)試.Net 4.0網(wǎng)站出現(xiàn)無厘頭、500錯(cuò)誤的解決方法
- IIS7.5 HTTP 錯(cuò)誤 500 調(diào)用loadlibraryex失敗的解決方法
- DirectoryEntry配置IIS7出現(xiàn)ADSI Error:未知錯(cuò)誤(0x80005000)
- IIS7.5 Error Code 0x8007007e HTTP 錯(cuò)誤 500.19的解決方法
- IIS7/iis7.5 HTTP Error 500.19 配置錯(cuò)誤由于權(quán)限不足而無法讀取配置文件的解決辦法
相關(guān)文章
windows服務(wù)器ssl證書創(chuàng)建、安裝及配置方法
這篇文章主要介紹了windows服務(wù)器ssl證書創(chuàng)建、安裝及配置方法,需要的朋友可以參考下2018-02-02
Windows 防火墻入站和出站規(guī)則小結(jié)
本文主要介紹了Windows防火墻的入站和出站規(guī)則,包括什么是入站和出站、Windows默認(rèn)的防火墻設(shè)置等,具有一定的參考價(jià)值,感興趣的可以了解一下2024-12-12
Windows Server 2012遠(yuǎn)程默認(rèn)端口3389的修改方法
本文主要介紹了Windows Server 2012遠(yuǎn)程默認(rèn)端口3389的修改方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-04-04
windows下Graphviz安裝及入門教程的實(shí)現(xiàn)方法
這篇文章主要介紹了windows下Graphviz安裝及入門教程的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09
win2003禁止用戶遠(yuǎn)程登錄的設(shè)置方法
有時(shí)候我們需要新增加一些用戶,又怕被黑客利用,我們就可以設(shè)置禁止這些用戶登錄服務(wù)器2013-09-09
win2003安裝wincache的步驟分享加速php運(yùn)行
wincache是微軟為配合fastcgi為推出的php加速器,如果你的php是在fastcgi模式下運(yùn)行的,一般php 5.3.*版本都是默認(rèn)fastcgi模式的,那么都可以通過wincache加速器來加速運(yùn)行php2013-08-08

