【问题标题】:i am running wcf service not working on iis我正在运行 wcf 服务,但无法在 iis 上运行
【发布时间】:2014-08-25 10:45:49
【问题描述】:

我第一次在 wcf 上工作,所以只创建了一个简单的 wcf,问题是当我从 Visual Studio 运行服务时它工作正常,但是当我将它部署到 iis 上时它会给出 HTTP 500 错误

我的网络配置文件如下

  <?xml version="1.0"?>
<configuration>
  <appSettings/>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WcfService2.Service1" behaviorConfiguration="servicebehavior">
        <endpoint address="" binding="webHttpBinding" contract="WcfService2.IService1" behaviorConfiguration="web"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="servicebehavior">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

和svc文件如下

namespace WcfService2
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    public class Service1 : IService1
    {
        public string JSONData(string id)
        {
            return "you requested prduct" + id ;
        }

        public void DoWork()
        {
        }
    }
}

界面如下

namespace WcfService2
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/json/{id}")]
        string JSONData(string id);

        void DoWork();
    }
}

【问题讨论】:

  • 大多数情况下 IIS 会显示错误详情
  • 您运行的是什么版本的 IIS?并发布错误。
  • 配置错误 此配置部分不能用于此路径。当该部分锁定在父级别时会发生这种情况。锁定是默认情况下 (overrideModeDefault="Deny"),或由具有 overrideMode="Deny" 或传统 allowOverride="false" 的位置标记显式设置。配置文件 \\?\C:\inetpub\wwwroot\web.config
  • 在 Windows 8 机器上运行

标签: c# asp.net wcf rest iis


【解决方案1】:

https://stackoverflow.com/a/11460220/2211593

我的 iis 服务器没有启用 HTTP 激活功能,所以经过大量谷歌搜索后,我找到了这个解决方案。对我来说非常有用我花了将近半天的时间来找到这个小问题的解决方案

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-18
    • 1970-01-01
    • 1970-01-01
    • 2011-09-07
    • 1970-01-01
    • 2016-09-26
    • 2020-09-16
    相关资源
    最近更新 更多