首页 > 解决方案 > ASP.NET WFC Method not found with 404 resource not found 错误

问题描述

我对这个问题发疯了:我写了这段代码:

[ServiceContract]
 public interface Idata
    {
     [WebInvoke(Method = "POST", UriTemplate = "getwinelist", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
        [OperationContract]
        List<Wine> GetWineList();
    }

在我的 web.config 文件中,我有这个:

<services>
  <service name="WineFid.data">
    <endpoint binding="webHttpBinding" contract="WineFid.Idata" behaviorConfiguration="webBehaviour" />
      </service>   
    </services>

以我的行为:

<endpointBehaviors>
   <behavior name="webBehaviour">
       <dataContractSerializer maxItemsInObjectGraph="2147483646" />
      </behavior>
    </endpointBehaviors>

如果我指向https://host.mydomain.net/main.svc它可以完美运行并向我展示经典的 Microsoft Web 服务页面,但是当我指向该方法时:

https://host.mydomain.net/main.svc/getwinelist

服务器响应“404 资源未找到......”我的错误在哪里?请注意,该服务托管在 Azure 上

提前致谢!

标签: asp.netazureweb-serviceswcf

解决方案


我对天蓝色没有任何想法。这是我认为找不到资源错误的原因,请尝试在标签下添加以下行<endpointBehaviors>并尝试是否有帮助。

<webHttp helpEnabled="true"  automaticFormatSelectionEnabled="true"/> 

推荐阅读