使用网站名称时不允许使用 WCF 服务方法 [英] WCF Service Method Not Allowed When Using WebsiteName
问题描述
我有以下服务合同
[OperationContract]
[WebInvoke(ResponseFormat = WebMessageFormat.Json, Method = "POST")]
List<Myobject> GetAll();
当我使用服务器(一个在线服务器)的 IP 调用服务方法时它可以工作,但是当我使用网站名称调用它时它不起作用,它返回方法不允许".服务器的 Url 格式为https://www.example.com/myweb(这不管用)例如 xxxx.xx.xx.xx/myweb 正在工作.请注意这些不是同一个服务器,它们是两个不同的服务器.
When I call the service method using the IP of the server (An online server) it works, but when I call it using the name of the website it does not work, it returns "Method Not Allowed". The Url of the server is of format "https://www.example.com/myweb (This is not working) While for example xxxx.xx.xx.xx/myweb is working. Please note the these are not the same server, they are two different servers.
其中 https://www.example.com/myweb 使用 HttpProxy (NginX), 至xxxx.xx.xx.xx/myweb
where https://www.example.com/myweb is redirected using an HttpProxy (NginX), to xxxx.xx.xx.xx/myweb
推荐答案
错误是由 NginX 产生的添加此语句
The error was generated by NginX Adding this statement
# To allow POST on static pages
error_page 405 =200 $uri;
到 nginX 配置文件解决了错误.
to the nginX config file solved the error.
查看此链接以获取更多信息:
Check this link to have more info:
http://invalidlogic.com/2011/04/12/serving-static-content-via-post-from-nginx/
这篇关于使用网站名称时不允许使用 WCF 服务方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!