HTTP 错误 500.19 - 内部服务器错误 请求的页面无法(WCF + REST + IIS7 + SSL)

发布于 2024-10-14 01:35:37 字数 6443 浏览 1 评论 0原文

我正在尝试使用 SSL 将我的 WCF REST 服务托管在 IIS 上,这让我度过了一段“花花公子”的时光。

环境:我正在带有本地IIS服务器的Windows7机器上进行测试。我已在我的开发盒上自行注册了一个证书,并且:

  1. 在 IIS 中创建了一个站点,以便通过 HTTPS 公开此 WCF 服务。
  2. 在此站点下创建一个应用程序并将其命名为“api”
  3. 在 IIS 中导航到我的站点
  4. 单击右侧“操作”面板中的“绑定...”。
  5. 单击“添加”
  6. 选择“https”并选择我的证书。

许多 REST 管道是通过使用 WcfRestContrib 库的 WCF 中的扩展来处理的。虽然从编程的角度来看这很有用,但当出现问题时却很少有文档记录。

我目前收到的错误是:

错误摘要

HTTP 错误 500.19 - 内部服务器错误 请求的页面无法

被访问是因为相关 该页面的配置数据是 无效的。详细错误信息 模块 IIS Web 核心 通知 BeginRequest 处理程序不 尚未确定错误代码0x8007000d 配置错误配置 文件 \?\C:\inetpub\eMobile\api\web.config 已请求 网址 https://172.xx.xx.254:443/api 身体的 路径 C:\inetpub\eMobile\api 登录 方式尚未确定 登录 用户尚未确定

配置源

   -1: 
    0:

我真的不确定我在这里做错了什么。到目前为止,我已尝试重新发送我的网站的功能委托,但没有成功。有什么想法吗?我的 web.config 有什么奇怪的地方吗?

谢谢。

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="e1ConnectionString" connectionString="Data Source=USSV112;Initial Catalog=e1;Integrated Security=True"
      providerName="System.Data.SqlClient" />
    <add name="e2ConnectionString" connectionString="Data Source=USSV112;Initial Catalog=e2;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  <system.web>
    <httpRuntime maxRequestLength="204800" executionTimeout="3600"/>
    <compilation debug="true" targetFramework="4.0">
    </compilation>
    <httpModules>
      <add name="ServiceAnonymityModule" type="WcfRestContrib.Web.ServiceAnonymityModule, WcfRestContrib, Version=1.0.6.107, Culture=neutral"/>
    </httpModules>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Users" stopProcessing="true">
          <match url="^rest/users/(.*)$"/>
          <action type="Rewrite" url="rest/Users.svc/{R:1}" />
        </rule>
      </rules>
    </rewrite>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="ServiceAnonymityModule"/>
      <add name="ServiceAnonymityModule" type="WcfRestContrib.Web.ServiceAnonymityModule, WcfRestContrib, Version=1.0.6.107, Culture=neutral"/>
    </modules>
  </system.webServer>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="messages" type="System.Diagnostics.XmlWriterTraceListener" initializeData="d:\Temp\WcfRestContribErrors.log" />
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="messages" type="System.Diagnostics.XmlWriterTraceListener" initializeData="d:\Temp\WcfRestContribMessages.log" />
        </listeners>
      </source>
    </sources>
    <trace autoflush="true"/>
  </system.diagnostics>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <extensions>
      <behaviorExtensions>
        <add name="webAuthentication" type="WcfRestContrib.ServiceModel.Configuration.WebAuthentication.ConfigurationBehaviorElement, WcfRestContrib, Version=1.0.6.107, Culture=neutral, PublicKeyToken=89183999a8dc93b5" />
        <add name="errorHandler" type="WcfRestContrib.ServiceModel.Configuration.ErrorHandler.BehaviorElement, WcfRestContrib, Version=1.0.6.107, Culture=neutral, PublicKeyToken=89183999a8dc93b5" />
        <add name="webFormatter" type="WcfRestContrib.ServiceModel.Configuration.WebDispatchFormatter.ConfigurationBehaviorElement, WcfRestContrib, Version=1.0.6.107, Culture=neutral, PublicKeyToken=89183999a8dc93b5" />
        <add name="webErrorHandler" type="WcfRestContrib.ServiceModel.Configuration.WebErrorHandler.ConfigurationBehaviorElement, WcfRestContrib, Version=1.0.6.107, Culture=neutral, PublicKeyToken=89183999a8dc93b5" />
      </behaviorExtensions>
    </extensions>
    <bindings>
      <customBinding>
        <binding name="HttpStreamedRest">
          <httpTransport maxReceivedMessageSize="209715200" manualAddressing="true"/>
        </binding>
        <binding name="HttpsStreamedRest">
          <httpsTransport maxReceivedMessageSize="209715200"  manualAddressing="true"/>
        </binding>
      </customBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Rest">
          <webAuthentication authenticationHandlerType="WcfRestContrib.ServiceModel.Dispatcher.WebBasicAuthenticationHandler, WcfRestContrib"
            usernamePasswordValidatorType="Engage.Mobile.WebServices.Runtime.SecurityValidator, Engage.Mobile.WebServices"
            requireSecureTransport="false" source="E Mobile" />
          <webFormatter>
            <formatters defaultMimeType="application/json">
              <formatter type="WcfRestContrib.ServiceModel.Dispatcher.Formatters.PoxDataContract, WcfRestContrib"
                mimeTypes="application/xml,text/xml" />
              <formatter type="WcfRestContrib.ServiceModel.Dispatcher.Formatters.DataContractJson, WcfRestContrib"
                mimeTypes="application/json" />
              <formatter type="WcfRestContrib.ServiceModel.Dispatcher.Formatters.FormUrlEncoded, WcfRestContrib"
                mimeTypes="application/x-www-form-urlencoded" />
            </formatters>
          </webFormatter>
          <errorHandler errorHandlerType="WcfRestContrib.ServiceModel.Web.WebErrorHandler, WcfRestContrib" />
          <webErrorHandler logHandlerType="Engage.Mobile.WebServices.Runtime.LogHandler, Engage.Mobile.WebServices" returnRawException="true" exceptionDataContractType="" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

I am having a "dandy" time trying to get my WCF REST service hosted on IIS with SSL.

Environment: I am testing on a Windows7 box with a local IIS server. I have self-registered a certificate on my dev box and have:

  1. Created a site in IIS for the purposes of exposing this WCF service via HTTPS.
  2. Created an application under this site and named it "api"
  3. Navigated to my site in IIS
  4. Clicked 'Bindings...' in the Actions panel on the right.
  5. Clicked 'Add'
  6. Selected 'https' and selected my certificate.

A lot of the REST plumbing is handled via extensions in WCF using the WcfRestContrib library. While this has been useful from a programming point of view, there is little out there in the way of documentation when something goes wrong.

The error I am currently getting is:

Error Summary

HTTP Error 500.19 - Internal Server Error The requested page cannot

be accessed because the related
configuration data for the page is
invalid. Detailed Error Information
Module IIS Web Core
Notification BeginRequest Handler Not
yet determined Error Code 0x8007000d
Config Error Config
File \?\C:\inetpub\eMobile\api\web.config
Requested
URL https://172.xx.xx.254:443/api
Physical
Path C:\inetpub\eMobile\api Logon
Method Not yet determined Logon
User Not yet determined

Config Source

   -1: 
    0:

I am really not surew what I am doing wrong here. So far I have tried resenting feature delegation for my site but that didn't work. Any ideas? Anything look odd in my web.config?

Thanks.

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="e1ConnectionString" connectionString="Data Source=USSV112;Initial Catalog=e1;Integrated Security=True"
      providerName="System.Data.SqlClient" />
    <add name="e2ConnectionString" connectionString="Data Source=USSV112;Initial Catalog=e2;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  <system.web>
    <httpRuntime maxRequestLength="204800" executionTimeout="3600"/>
    <compilation debug="true" targetFramework="4.0">
    </compilation>
    <httpModules>
      <add name="ServiceAnonymityModule" type="WcfRestContrib.Web.ServiceAnonymityModule, WcfRestContrib, Version=1.0.6.107, Culture=neutral"/>
    </httpModules>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Users" stopProcessing="true">
          <match url="^rest/users/(.*)$"/>
          <action type="Rewrite" url="rest/Users.svc/{R:1}" />
        </rule>
      </rules>
    </rewrite>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="ServiceAnonymityModule"/>
      <add name="ServiceAnonymityModule" type="WcfRestContrib.Web.ServiceAnonymityModule, WcfRestContrib, Version=1.0.6.107, Culture=neutral"/>
    </modules>
  </system.webServer>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="messages" type="System.Diagnostics.XmlWriterTraceListener" initializeData="d:\Temp\WcfRestContribErrors.log" />
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="messages" type="System.Diagnostics.XmlWriterTraceListener" initializeData="d:\Temp\WcfRestContribMessages.log" />
        </listeners>
      </source>
    </sources>
    <trace autoflush="true"/>
  </system.diagnostics>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <extensions>
      <behaviorExtensions>
        <add name="webAuthentication" type="WcfRestContrib.ServiceModel.Configuration.WebAuthentication.ConfigurationBehaviorElement, WcfRestContrib, Version=1.0.6.107, Culture=neutral, PublicKeyToken=89183999a8dc93b5" />
        <add name="errorHandler" type="WcfRestContrib.ServiceModel.Configuration.ErrorHandler.BehaviorElement, WcfRestContrib, Version=1.0.6.107, Culture=neutral, PublicKeyToken=89183999a8dc93b5" />
        <add name="webFormatter" type="WcfRestContrib.ServiceModel.Configuration.WebDispatchFormatter.ConfigurationBehaviorElement, WcfRestContrib, Version=1.0.6.107, Culture=neutral, PublicKeyToken=89183999a8dc93b5" />
        <add name="webErrorHandler" type="WcfRestContrib.ServiceModel.Configuration.WebErrorHandler.ConfigurationBehaviorElement, WcfRestContrib, Version=1.0.6.107, Culture=neutral, PublicKeyToken=89183999a8dc93b5" />
      </behaviorExtensions>
    </extensions>
    <bindings>
      <customBinding>
        <binding name="HttpStreamedRest">
          <httpTransport maxReceivedMessageSize="209715200" manualAddressing="true"/>
        </binding>
        <binding name="HttpsStreamedRest">
          <httpsTransport maxReceivedMessageSize="209715200"  manualAddressing="true"/>
        </binding>
      </customBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Rest">
          <webAuthentication authenticationHandlerType="WcfRestContrib.ServiceModel.Dispatcher.WebBasicAuthenticationHandler, WcfRestContrib"
            usernamePasswordValidatorType="Engage.Mobile.WebServices.Runtime.SecurityValidator, Engage.Mobile.WebServices"
            requireSecureTransport="false" source="E Mobile" />
          <webFormatter>
            <formatters defaultMimeType="application/json">
              <formatter type="WcfRestContrib.ServiceModel.Dispatcher.Formatters.PoxDataContract, WcfRestContrib"
                mimeTypes="application/xml,text/xml" />
              <formatter type="WcfRestContrib.ServiceModel.Dispatcher.Formatters.DataContractJson, WcfRestContrib"
                mimeTypes="application/json" />
              <formatter type="WcfRestContrib.ServiceModel.Dispatcher.Formatters.FormUrlEncoded, WcfRestContrib"
                mimeTypes="application/x-www-form-urlencoded" />
            </formatters>
          </webFormatter>
          <errorHandler errorHandlerType="WcfRestContrib.ServiceModel.Web.WebErrorHandler, WcfRestContrib" />
          <webErrorHandler logHandlerType="Engage.Mobile.WebServices.Runtime.LogHandler, Engage.Mobile.WebServices" returnRawException="true" exceptionDataContractType="" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

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

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

发布评论

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

评论(3

安静被遗忘 2024-10-21 01:35:54

您可以尝试在服务上启用跟踪,以查看请求是否到达服务或在 IIS 本身上失败。如果它到达您的服务,那么跟踪将在失败的地方找到确切的错误。要启用跟踪,请点击此链接

You can try enabling tracing on your service to see if the request is reaching the service or failing on IIS itself. If it is reaching your service then tracing would pick up the exact error on where it is failing. To enable tracing follow this link

谁对谁错谁最难过 2024-10-21 01:35:46

我在此帖子中发布了类似的答案,并且有类似的答案跨过这些错误。

您的 web.config 中有一个重写元素,如果没有安装 URL 重写,IIS 无法识别此元素并抛出您当前看到的错误。安装URL Rewrite,这应该可以工作。

I posted a similar answer in this thread, and there are similar answers across SO for these errors.

You have a rewrite element in your web.config, and without URL Rewrite installed IIS does not recognise this element and throws the error you currently see. Install URL Rewrite and this should work.

强辩 2024-10-21 01:35:43

它看起来非常像这个线程

建议的答案是

  1. 右键点击您网站所在的文件夹:“C:\Users\NAME\SiteName”并选择“属性”
  2. 选择“安全”选项卡并点击“编辑”
  3. 添加..并输入“IIS_IUSRS”

It looks very much like this thread

The proposed answer was

  1. Right click the folder where your site is located: "C:\Users\NAME\SiteName" and selecting Properties
  2. Select the Security tab and click on Edit
  3. Add.. and type in "IIS_IUSRS"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文