首頁 php教程 PHP开发 IIS7報500.23錯誤的原因分析及解決方法

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

Jan 06, 2017 pm 04:21 PM

 背景:今天公司終端上有一個功能打開異常,報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

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系統,解釋
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆樹的耳語 - 如何解鎖抓鉤
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1672
14
CakePHP 教程
1428
52
Laravel 教程
1332
25
PHP教程
1276
29
C# 教程
1256
24