IIS 7.5在Restful WCF 4.0上出现错误

15

我一直在尝试创建一个简单的RESTful WCF服务,用于返回JSON数据。如果在开发服务器上运行它是可以工作的,但是当我将其部署到IIS 7.5上时,通过http://localhost:70访问它时会遇到以下错误:

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

Config Error 配置节'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比较陌生。

能否有人帮忙?或者有人已经遇到过同样的问题并且已经解决了?

4个回答

24

你确定你已经为你的网站配置了运行ASP .NET 4.0的IIS应用程序池吗?

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

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


谢谢你,我已经检查并发现我的应用程序创建了自己的应用程序池,使用的是 ASP.NET 2.0 而不是 4.0。现在它可以工作了。非常感谢你。 - mark vanzuela

2

我在一个运行.NET 4.0的w2008 x64上遇到了同样的错误;安装SP2后,问题消失了。


1
这个问题出现在未安装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或KB文章958854中提到的热补丁。


这正是我们升级一些旧的x86应用服务器从IIS 6(2003)到IIS 7(2008 SP2)后所面临的问题。感谢分享解决方法! - SliverNinja - MSFT

-1

很抱歉提出这样一个对一些人来说可能很明显的问题,但如果您能澄清最后一步,可能会帮助其他人(主要是我):

然后前往应用程序池...

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

如果你不能确定,我习惯于为大公司工作,而现在我正在扮演开发人员和IT主管。

谢谢

好的,在进行了10秒钟的研究后(我张开了眼睛),并在IIS Manager中的Sites上方查看。

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接