Restful WCF 4.0 上的 IIS 7.5 错误

发布于 2024-09-19 12:47:07 字数 1582 浏览 2 评论 0原文

我一直在尝试做一个简单的restful wcf 服务,它将返回JSON。如果我在开发服务器中运行它,它就可以工作。但是,如果我将其部署在 IIS 7.5 上,当我使用 http://localhost:70< 访问它时,将会出现此错误/a>

HTTP 错误 500.19 - 内部服务器 错误 请求的页面无法 访问是因为相关 该页面的配置数据是 无效。

配置错误配置部分 无法读取“standardEndpoints” 因为它缺少一个部分 声明

这是我的配置文件: 这是VS2010生成的默认文件。

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </modules>
  </system.webServer>

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <standardEndpoints>
      <webHttpEndpoint>
        <!-- 
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
            via the attributes on the <standardEndpoint> element below
        -->
        <standardEndpoint name="LocationService" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>

</configuration>

我是 WCF 新手,特别是 .net 4.0 和 IIS 7.5。

有人可以帮忙吗?或者有人经历过同样的事情并且已经解决了?

I've been trying to do a simple restful wcf service that will return JSON. Its working if i will run it in the development server. However if I deploy it on IIS 7.5, i will have this error when i accessed it using http://localhost:70

HTTP Error 500.19 - Internal Server
Error The requested page cannot be
accessed because the related
configuration data for the page is
invalid.

Config Error The configuration section
'standardEndpoints' cannot be read
because it is missing a section
declaration

Here is my configuration file: This is the default file generated by the VS2010.

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </modules>
  </system.webServer>

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <standardEndpoints>
      <webHttpEndpoint>
        <!-- 
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
            via the attributes on the <standardEndpoint> element below
        -->
        <standardEndpoint name="LocationService" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>

</configuration>

Im new to WCF specially on .net 4.0 and IIS 7.5.

Can anybody help? Or anybody has experienced the same and has fixed already?

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

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

发布评论

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

评论(4

猫九 2024-09-26 12:47:07

您是否确实将站点的 IIS 应用程序池配置为与 ASP .NET 4.0 一起运行?

在 IIS 管理器中右键单击您的虚拟目录 >管理应用程序>高级设置>读取应用程序池名称。

然后转到应用程序池,找到该名称并确保 .NET Framework 列显示 v4.0。

Do you definitely have the IIS application pool for your site configured to run with ASP .NET 4.0?

Right click your Virtual Directory in IIS Manager > Manage Application > Advanced Settings > read the app pool name.

Then go to Application Pools, find that name and make sure the .NET Framework column says v4.0.

谁把谁当真 2024-09-26 12:47:07

我在运行 .net 4.0 的应用程序池的 w2008 x64 上遇到了同样的错误;安装SP2后问题消失

I had the same error on a w2008 x64 with the app pool running .net 4.0; after installing SP2 the issue disappeared

明媚殇 2024-09-26 12:47:07

在未安装 Service Pack 2 的 Windows Server 2008 上会出现此问题。要解决此问题,请安装 Windows Server 2008 Service Pack 2。

取自 Ram Poornalingam 2009 年 10 月 26 日的 WebLog 条目

如果您在 Web 应用程序(IIS 中托管的内容)中遇到以下错误“无法读取配置节,因为它缺少节声明”

示例

“无法读取配置节“standardEndpoints”,因为它缺少节声明”

“无法读取配置节‘tracking’,因为它缺少节声明”

那么您需要安装Vista/Win2k8的SP2或知识库文章958854中提到的修补程序。

This issue can be seen on Windows Server 2008 without service pack 2 installed. To fix the problem install Windows Server 2008 Service Pack 2.

Taken from Ram Poornalingam's WebLog entry from the 26th October 2009:

If you encounter the following error in your web application (things hosted in IIS) “The configuration section cannot be read because it is missing a section declaration"

examples

“The configuration section 'standardEndpoints' cannot be read because it is missing a section declaration”

“The configuration section ‘tracking’ cannot be read because it is missing a section declaration”

then you need to install either SP2 of Vista/Win2k8 or the hotfix mentioned in KB article 958854.

眼眸里的快感 2024-09-26 12:47:07

很抱歉问一个对某些人来说似乎显而易见的问题,但如果您能澄清最后一步,它可能会帮助其他人(主要是我):

然后转到应用程序池...

在哪里可以找到应用程序池?

如果你看不出我习惯在大公司工作,其他人为我做这件事,而现在我扮演开发人员和 IT 总监。

谢谢

好的,经过 10 秒的研究(我睁开眼睛),查看了 IIS 管理器中站点的正上方

在此处输入图像描述

Sorry to ask a question that may seem obvious to some, but it might help others (mainly me) if you could clarify the last step:

Then go to Application Pools...

Where do I find Application Pools ?

If you can't tell I am used to working for big companies where someone else did that for me and now I am playing developer and IT director.

Thanks

Ok, after 10 seconds of research (I opened my eyes) and looked right above Sites in IIS Manager

enter image description here

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