温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

IIS7报500.23错误的解决方法

发布时间:2020-07-31 10:29:18 来源:网络 阅读:1447 作者:pizibaidu 栏目:开发技术

背景:今天公司终端上有一个功能打开异常,报500错误,我用Fiddler找到链接,然后在IE里打开,报500.23错误:检测到在集成的托管管道模式下不适用的ASP.NET设置。后台是一个IIS7tomcat7集成的环境,此处记录一下。

 

HTTP 错误 500.23 - Internal Server Error

检测到在集成的托管管道模式下不适用的 ASP.NET 设置。

IIS7报500.23错误的解决方法


 

为什么会出现以上错误?

IIS7的应用程序池有两种模式,一种是集成模式,一种是经典模式

经典模式则是我们以前习惯的IIS 6 的方式。

如果使用集成模式,那么对自定义的httpModules httpHandlers 就要修改配置文件,需要将他们转移到<modules><hanlders>节里去。

两种解决方法:

第一种方法、配置应用程序池

IIS7上配置应用程序池,并且将程序池的模式改为经典,之后一切正常。如图:



IIS7报500.23错误的解决方法


用了IIS7.x,但实际只发挥了6的功能,另外,在一些ASP.NET MVC程序中的效果也不好,所以,我们尝试以下解决方法:


第二种方法、修改web.config配置文件:

注: web.config路径C:\inetpub\wwwroot\web.config

例如原先设置(你的环境中可能没有httpModuleshttpHandlers节点)

<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没有httpModuleshttpHandlers节点,则直接在节点system.webServer中添加:

<validation validateIntegratedModeConfiguration="false" /> 

禁止验证集成模式,来避免错误。

 


 

IIS Log的位置

IIS 6.0的Log日志存储在:

c:\windows\system32\logfiles\

 

IIS 7 Log存储在:

%SystemDrive%\inetpub\logs\LogFiles

 

经过我的测试, IIS日志是即时写入的, 不需要IIS reset.

 

IIS 6, 7的日志写入按不同站点写入不同的文件夹, 位置文件夹的格式都是"w3svc{siteId}".

IIS6里, 查看站点ID的方式是通过IIS log的文件夹的名字来确定Site ID.

IIS7中, 在IIS管理器中的advanced settings中, General里的ID就是Site ID, 然后你需要通过这个ID来定位LogFiles文件夹中哪一个文件夹属于你要查看的站点.


 

Intergrated和Classic的区别

 

IIS7的Application Pools有两种mode,一种是Integrated,一种是classic。如果使用Integrated模式,那么对自定义的httpModules和httpHandlers就要修改配置文件了,需要将他们转移到<modules>和<hanlders>节里去。

IIS7的两种模式和IIS6有什么区别?

IIS7.0 Integrated modeasp.net 的modules和handlers从<system.webServer>下的<modules> 和<handlers>里读取,以前的<system.web>下的<httpModules> 和<httpHandlers>配置节会被忽略,如果设置禁止验证(disabledvalidation),是不会产生错误的。

IIS7.0 Classic mode 与 以上情况是相反的,<modules>和<handlers>会被忽略。

 

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.

经典模式是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 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的请求管道是紧密集成 的,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)里的相同定义,但记得要加上<validation validateIntegratedModeConfiguration="false"/>,不然IIS7会因为定义重覆出现而发生错误。

 


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI