Wcf Json Post在VS中工作,但在IIS 7.5中不工作

时间:2012-03-28 13:01:13

标签: json wcf iis rest post

我在IIS中有一个部分工作的WCF服务。我的GET请求工作正常,但POSTS仅在我在Visual Studio中时才有效。当我使用IIS时,我得到错误400错误请求。任何人都可以帮助解决这个问题。这是一些代码。

public string AddHost(Host host)
{
    HostDal dal = new HostDal();
    dal.CreateHost(host);
    return Utils.Message;
}

接口

[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/addhost", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string AddHost(Host host); 

使用Fiddler我发布的json是这样的:

{
“名称”: “newhost19”,
“MAC”: “CA:99:11:22:33:43”,
“图像”: “测试”,
“本集团”: “测试”,
“说明”: “测试”,
“内核”: “测试”,
“BootImage”: “测试”,
“参数数量”: “测试”,
“脚本”:“测试”
}

就像我说的如果我使用IIS发布到 http://localhost/web/ClientSvc.svc/addhost ,我会收到错误400.
如果我使用VS发布到 http:// localhost:49807 / web / ClientSvc.svc / addhost 它工作正常
感谢

1 个答案:

答案 0 :(得分:0)

如果有人感兴趣,最终会成为文件夹权限问题。我还不确定为什么GETS会工作