WCF Web部署HTTP错误404 - 未找到

时间:2017-08-25 11:07:18

标签: asp.net vb.net web-services wcf web-deployment

我在vb.net中创建了一个REST WCF Web服务,并使用Web Deploy将其发布到1& 1主机服务器。在尝试拨打其中一项服务时,我一直在接收:

  

HTTP错误404 - 未找到。

     

您要查找的资源已被删除,名称已更改或暂时不可用。

我查看了wwwroot目录,我可以找到.svc文件和web.config,所以我无法弄清楚它为什么找不到它。我正在拨打的电话是:http://localhost/Service1.svc/GetTimesheetDetails/1/1/11256/2017-8-9

<OperationContract()>
    <WebInvoke(Method:="GET", ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Wrapped, UriTemplate:="GetTimesheetDetails/{userid}/{organisationid}/{jobid}/{sdate}")>
    Function GetTimesheetDetails(ByVal userid As String, ByVal organisationid As String, ByVal jobid As String, ByVal sdate As String) As List(Of JobEngineerTime)

我已经测试了在Visual Studio上运行它们的这些调用,它运行正常,但遗憾的是我无法通过1&amp; 1服务器运行它。

这是我的web.config:

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

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <!--Disabled custom errors to allow display of detailed errors.-->
    <!--<customErrors mode="Off"/>-->
    <customErrors mode="RemoteOnly" defaultRedirect="~/Errors/500.htm">
      <error statusCode="404" redirect="~/Errors/404.htm"/>
    </customErrors>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webBehaviour">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="metadataBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="metadataBehavior" name="WCFTimesheetWebService.Service1">
        <endpoint address="" behaviorConfiguration="webBehaviour"
          binding="webHttpBinding" contract="WCFTimesheetWebService.IService1" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="metadataBehavior" name="WCFTimesheetWebService.Service2">
        <endpoint address="" behaviorConfiguration="webBehaviour"
          binding="webHttpBinding" contract="WCFTimesheetWebService.IService2" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="metadataBehavior" name="WCFTimesheetWebService.Service3">
        <endpoint address="" behaviorConfiguration="webBehaviour"
          binding="webHttpBinding" contract="WCFTimesheetWebService.IService3" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <!-- Allowing Cross-Origin Resource Sharing (CORS) - The httpProtocol settings allow web services to be called from external domains using JavaScript-->
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type, Accept" />
      </customHeaders>
    </httpProtocol>
    <modules runAllManagedModulesForAllRequests="true"/>
    <httpErrors errorMode="Detailed" />
    <validation validateIntegratedModeConfiguration="false"/>
    <!--
        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>

1 个答案:

答案 0 :(得分:0)

IIS“Handler Mappings”中缺少几个映射。要解决这个问题,我所要做的就是点击“Handler Mappings”中的“Revert to Parent”,恢复丢失的映射并开始工作。