asp.net - 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 上
提前致谢!
解决方案
我对天蓝色没有任何想法。这是我认为找不到资源错误的原因,请尝试在标签下添加以下行<endpointBehaviors>
并尝试是否有帮助。
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true"/>
推荐阅读
- google-cloud-ai-platform-pipelines - 无法在 AI Platform Pipelines 上查看 TFX 可视化
- javascript - 奥赛罗极小极大算法在 React.js 中不起作用
- python - 如何在 Dockerfile CMD 和 ENTRYPOINT 执行模式下正确转义 [] 字符?
- c# - 在后面的代码中将依赖属性绑定到另一个依赖属性
- python - 在 Notebook - Odoo 14 中根据组权限限制添加评论
- reactjs - 使用 Create-React-App 动态导入图像
- spring - 在 Spring Boot 中以编程方式删除和重新创建表
- python - Python textwrap:终端打印与写入文件的不同结果
- php - 比较多个字符串并在php中找到相似的子字符串
- json - 如何使用 jq 写入 JSON 文件而不更改 Powershell 的二进制文件?