【问题标题】:WCF Web Deploy HTTP Error 404 - Not FoundWCF Web 部署 HTTP 错误 404 - 未找到
【发布时间】:2018-02-03 10:06:27
【问题描述】:

我在 vb.net 中创建了一个 REST WCF Web 服务,并使用 Web Deploy 将其发布到 1&1 Host Server。尝试调用其中一项服务时,我不断收到:

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&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&1 交谈或查看他们的支持论坛。

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


【解决方案1】:

IIS“处理程序映射”中缺少几个映射。为了解决这个问题,我所要做的就是点击“处理程序映射”中的“恢复到父级”,它恢复了丢失的映射并开始工作。

【讨论】:

    猜你喜欢
    • 2019-04-02
    • 2015-12-29
    • 2013-05-10
    • 2021-01-15
    • 2022-11-11
    • 1970-01-01
    • 1970-01-01
    • 2022-06-10
    • 2023-03-30
    相关资源
    最近更新 更多