ASP.net openID 项目模板和 IIS 7.5

发布于 2024-11-16 03:58:58 字数 11708 浏览 2 评论 0原文

我正在使用 openID-InfoCard RP 模板 创建一个使用 openID 的项目,该项目在我的电脑上运行良好但是当我将网站复制到我们的 IIS 服务器并尝试浏览它时,我收到此错误:

HTTP 错误 500.22 - 内部服务器错误 检测到不适用于集成托管管道模式的 ASP.NET 设置。

应用程序池设置为.net 4.0 这是 web.config 文件:

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
    <configSections>
        <!--<section name="uri" type="System.Configuration.UriSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>-->
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" requirePermission="false"/>
        <section name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection" requirePermission="false" allowLocation="true"/>
    </configSections>
    <!-- The uri section is necessary to turn on .NET 3.5 support for IDN (international domain names),
         which is necessary for OpenID urls with unicode characters in the domain/host name. 
         It is also required to put the Uri class into RFC 3986 escaping mode, which OpenID and OAuth require. -->
    <uri>
        <idn enabled="All"/>
        <iriParsing enabled="true"/>
    </uri>
    <system.net>
        <defaultProxy enabled="true"/>
        <settings>
            <!-- This setting causes .NET to check certificate revocation lists (CRL) 
                 before trusting HTTPS certificates.  But this setting tends to not 
                 be allowed in shared hosting environments. -->
            <servicePointManager checkCertificateRevocationList="false"/>
        </settings>
    </system.net>
    <!-- this is an optional configuration section where aspects of dotnetopenauth can be customized -->
    <dotNetOpenAuth>
        <messaging>
            <untrustedWebRequest>
                <whitelistHosts>
                    <!--<add name="localhost" />-->
                </whitelistHosts>
            </untrustedWebRequest>
        </messaging>
        <openid>
            <relyingParty>
                <security requireSsl="false">
                    <!-- Uncomment the trustedProviders tag if your relying party should only accept positive assertions from a closed set of OpenID Providers. -->
                    <!--<trustedProviders rejectAssertionsFromUntrustedProviders="true">
                        <add endpoint="https://www.google.com/accounts/o8/ud" />
                    </trustedProviders>-->
                </security>
                <behaviors>
                    <!-- The following OPTIONAL behavior allows RPs to use SREG only, but be compatible
                         with OPs that use Attribute Exchange (in various formats). -->
                    <add type="DotNetOpenAuth.OpenId.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth"/>
                </behaviors>
                <store type="RelyingPartyLogic.RelyingPartyApplicationDbStore, RelyingPartyLogic"/>
            </relyingParty>
        </openid>
        <oauth>
            <serviceProvider>
                <store type="RelyingPartyLogic.NonceDbStore, RelyingPartyLogic"/>
            </serviceProvider>
        </oauth>
        <!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. -->
        <reporting enabled="false"/>
    </dotNetOpenAuth>
    <!-- log4net is a 3rd party (free) logger library that DotNetOpenAuth will use if present but does not require. -->
    <log4net>
        <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
            <bufferSize value="100"/>
            <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
            <connectionString value="Data Source=vs-SQLDev;Initial Catalog=Portal;Persist Security Info=True;User ID=***;Password=***;Enlist=False"/>
            <commandText value="INSERT INTO [Log] ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)"/>
            <parameter>
                <parameterName value="@log_date"/>
                <dbType value="DateTime"/>
                <layout type="log4net.Layout.RawTimeStampLayout"/>
            </parameter>
            <parameter>
                <parameterName value="@thread"/>
                <dbType value="String"/>
                <size value="255"/>
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%thread"/>
                </layout>
            </parameter>
            <parameter>
                <parameterName value="@log_level"/>
                <dbType value="String"/>
                <size value="50"/>
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%level"/>
                </layout>
            </parameter>
            <parameter>
                <parameterName value="@logger"/>
                <dbType value="String"/>
                <size value="255"/>
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%logger"/>
                </layout>
            </parameter>
            <parameter>
                <parameterName value="@message"/>
                <dbType value="String"/>
                <size value="4000"/>
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%message"/>
                </layout>
            </parameter>
            <parameter>
                <parameterName value="@exception"/>
                <dbType value="String"/>
                <size value="2000"/>
                <layout type="log4net.Layout.ExceptionLayout"/>
            </parameter>
        </appender>
        <!-- Setup the root category, add the appenders and set the default level -->
        <root>
            <level value="WARN"/>
            <appender-ref ref="AdoNetAppender"/>
        </root>
        <!-- Specify the level for some specific categories -->
        <logger name="DotNetOpenAuth">
            <level value="WARN"/>
        </logger>
        <logger name="DotNetOpenAuth.OpenId">
            <level value="INFO"/>
        </logger>
        <logger name="DotNetOpenAuth.OAuth">
            <level value="INFO"/>
        </logger>
    </log4net>
    <appSettings/>
    <connectionStrings>
        <!-- Remember to keep this connection string in sync with the one (if any) that appears in the log4net section. -->
        <add name="DatabaseEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=vs-SQLDev;Initial Catalog=Portal;Persist Security Info=True;User ID=***;Password=***;Enlist=False&quot;" providerName="System.Data.EntityClient"/>
    </connectionStrings>
    <system.web>
        <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <remove assembly="DotNetOpenAuth.Contracts"/>
                <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
                <add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
        </compilation>
        <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
        <authentication mode="Forms">
            <forms loginUrl="~/login.aspx" name="Portal"/> 
        </authentication>
        <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.
            -->
        <customErrors mode="RemoteOnly"/>
        <httpModules>
            <add name="OAuthAuthenticationModule" type="RelyingPartyLogic.OAuthAuthenticationModule, RelyingPartyLogic"/>
            <add name="Database" type="RelyingPartyLogic.Database, RelyingPartyLogic"/>
        </httpModules>
        <roleManager enabled="true" defaultProvider="Database">
            <providers>
                <add name="Database" type="RelyingPartyLogic.DataRoleProvider, RelyingPartyLogic"/>
            </providers>
        </roleManager>
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
    <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
    <system.webServer>
        <modules>
            <add name="OAuthAuthenticationModule" type="RelyingPartyLogic.OAuthAuthenticationModule, RelyingPartyLogic"/>
            <add name="Database" type="RelyingPartyLogic.Database, RelyingPartyLogic"/>
        </modules>
    </system.webServer>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="DataApiBehavior">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                    <serviceAuthorization serviceAuthorizationManagerType="OAuthAuthorizationManager, __code" principalPermissionMode="Custom"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <!--<service behaviorConfiguration="DataApiBehavior" name="DataApi">
            </service>-->
        </services>
    </system.serviceModel>
    <location path="default.aspx">
        <system.web>
            <authorization>
                <allow users="*"/>
            </authorization>
        </system.web>
    </location>
</configuration>

I'm using the openID-InfoCard RP template to create a project which uses openID the project works fine on my PC but when I copy the website to our IIS server and try to browse it I'm getting this error :

HTTP Error 500.22 - Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

the application pool is set to .net 4.0
and this the web.config file :

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
    <configSections>
        <!--<section name="uri" type="System.Configuration.UriSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>-->
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" requirePermission="false"/>
        <section name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection" requirePermission="false" allowLocation="true"/>
    </configSections>
    <!-- The uri section is necessary to turn on .NET 3.5 support for IDN (international domain names),
         which is necessary for OpenID urls with unicode characters in the domain/host name. 
         It is also required to put the Uri class into RFC 3986 escaping mode, which OpenID and OAuth require. -->
    <uri>
        <idn enabled="All"/>
        <iriParsing enabled="true"/>
    </uri>
    <system.net>
        <defaultProxy enabled="true"/>
        <settings>
            <!-- This setting causes .NET to check certificate revocation lists (CRL) 
                 before trusting HTTPS certificates.  But this setting tends to not 
                 be allowed in shared hosting environments. -->
            <servicePointManager checkCertificateRevocationList="false"/>
        </settings>
    </system.net>
    <!-- this is an optional configuration section where aspects of dotnetopenauth can be customized -->
    <dotNetOpenAuth>
        <messaging>
            <untrustedWebRequest>
                <whitelistHosts>
                    <!--<add name="localhost" />-->
                </whitelistHosts>
            </untrustedWebRequest>
        </messaging>
        <openid>
            <relyingParty>
                <security requireSsl="false">
                    <!-- Uncomment the trustedProviders tag if your relying party should only accept positive assertions from a closed set of OpenID Providers. -->
                    <!--<trustedProviders rejectAssertionsFromUntrustedProviders="true">
                        <add endpoint="https://www.google.com/accounts/o8/ud" />
                    </trustedProviders>-->
                </security>
                <behaviors>
                    <!-- The following OPTIONAL behavior allows RPs to use SREG only, but be compatible
                         with OPs that use Attribute Exchange (in various formats). -->
                    <add type="DotNetOpenAuth.OpenId.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth"/>
                </behaviors>
                <store type="RelyingPartyLogic.RelyingPartyApplicationDbStore, RelyingPartyLogic"/>
            </relyingParty>
        </openid>
        <oauth>
            <serviceProvider>
                <store type="RelyingPartyLogic.NonceDbStore, RelyingPartyLogic"/>
            </serviceProvider>
        </oauth>
        <!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. -->
        <reporting enabled="false"/>
    </dotNetOpenAuth>
    <!-- log4net is a 3rd party (free) logger library that DotNetOpenAuth will use if present but does not require. -->
    <log4net>
        <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
            <bufferSize value="100"/>
            <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
            <connectionString value="Data Source=vs-SQLDev;Initial Catalog=Portal;Persist Security Info=True;User ID=***;Password=***;Enlist=False"/>
            <commandText value="INSERT INTO [Log] ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)"/>
            <parameter>
                <parameterName value="@log_date"/>
                <dbType value="DateTime"/>
                <layout type="log4net.Layout.RawTimeStampLayout"/>
            </parameter>
            <parameter>
                <parameterName value="@thread"/>
                <dbType value="String"/>
                <size value="255"/>
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%thread"/>
                </layout>
            </parameter>
            <parameter>
                <parameterName value="@log_level"/>
                <dbType value="String"/>
                <size value="50"/>
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%level"/>
                </layout>
            </parameter>
            <parameter>
                <parameterName value="@logger"/>
                <dbType value="String"/>
                <size value="255"/>
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%logger"/>
                </layout>
            </parameter>
            <parameter>
                <parameterName value="@message"/>
                <dbType value="String"/>
                <size value="4000"/>
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%message"/>
                </layout>
            </parameter>
            <parameter>
                <parameterName value="@exception"/>
                <dbType value="String"/>
                <size value="2000"/>
                <layout type="log4net.Layout.ExceptionLayout"/>
            </parameter>
        </appender>
        <!-- Setup the root category, add the appenders and set the default level -->
        <root>
            <level value="WARN"/>
            <appender-ref ref="AdoNetAppender"/>
        </root>
        <!-- Specify the level for some specific categories -->
        <logger name="DotNetOpenAuth">
            <level value="WARN"/>
        </logger>
        <logger name="DotNetOpenAuth.OpenId">
            <level value="INFO"/>
        </logger>
        <logger name="DotNetOpenAuth.OAuth">
            <level value="INFO"/>
        </logger>
    </log4net>
    <appSettings/>
    <connectionStrings>
        <!-- Remember to keep this connection string in sync with the one (if any) that appears in the log4net section. -->
        <add name="DatabaseEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string="Data Source=vs-SQLDev;Initial Catalog=Portal;Persist Security Info=True;User ID=***;Password=***;Enlist=False"" providerName="System.Data.EntityClient"/>
    </connectionStrings>
    <system.web>
        <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <remove assembly="DotNetOpenAuth.Contracts"/>
                <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
                <add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
        </compilation>
        <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
        <authentication mode="Forms">
            <forms loginUrl="~/login.aspx" name="Portal"/> 
        </authentication>
        <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.
            -->
        <customErrors mode="RemoteOnly"/>
        <httpModules>
            <add name="OAuthAuthenticationModule" type="RelyingPartyLogic.OAuthAuthenticationModule, RelyingPartyLogic"/>
            <add name="Database" type="RelyingPartyLogic.Database, RelyingPartyLogic"/>
        </httpModules>
        <roleManager enabled="true" defaultProvider="Database">
            <providers>
                <add name="Database" type="RelyingPartyLogic.DataRoleProvider, RelyingPartyLogic"/>
            </providers>
        </roleManager>
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
    <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
    <system.webServer>
        <modules>
            <add name="OAuthAuthenticationModule" type="RelyingPartyLogic.OAuthAuthenticationModule, RelyingPartyLogic"/>
            <add name="Database" type="RelyingPartyLogic.Database, RelyingPartyLogic"/>
        </modules>
    </system.webServer>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="DataApiBehavior">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                    <serviceAuthorization serviceAuthorizationManagerType="OAuthAuthorizationManager, __code" principalPermissionMode="Custom"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <!--<service behaviorConfiguration="DataApiBehavior" name="DataApi">
            </service>-->
        </services>
    </system.serviceModel>
    <location path="default.aspx">
        <system.web>
            <authorization>
                <allow users="*"/>
            </authorization>
        </system.web>
    </location>
</configuration>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

调妓 2024-11-23 03:58:58

您可以通过更改 IIS Web 模式(使其不是管道模式)来解决该问题。或者,您可以查看错误的调用堆栈,以确定哪些代码在管道模式下不起作用并进行更改(请随意将有问题的代码添加到您的问题中,或使用 DotNetOpenAuth 提交错误报告)。

You can probably workaround the problem by changing the IIS web pool mode (so that it's not pipeline mode). Alternatively you could look at the callstack of the error to determine what code doesn't work in pipeline mode and change it (feel free to add the offending code to your question or file a bug report with DotNetOpenAuth on that).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文