Restful WCF 4.0上的IIS 7.5错误

mar*_*ela 15 wcf web-config c#-4.0

我一直在尝试做一个简单的restful wcf服务,它将返回JSON.它的工作,如果我将在开发服务器中运行它.但是,如果我在IIS 7.5上部署它,当我使用http:// localhost:70访问它时,我将遇到此错误

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>
Run Code Online (Sandbox Code Playgroud)

我是WCF的新手,特别是在.net 4.0和IIS 7.5上.

有人可以帮忙吗?或者任何人都经历过同样的事情并且已经修好了?

Jef*_*eff 24

您的网站的IIS应用程序池是否配置为使用ASP .NET 4.0运行?

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

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