【发布时间】:2014-02-04 12:26:08
【问题描述】:
我在我的 Web 应用程序中使用 MVC5、WebAPI、WCF Restful 服务。
当我朗姆酒 WCF 宁静的服务时,我得到了不同的反应。有些服务给了我适当的回应,有些没有。我正在我的机器上运行这个应用程序。
我使用 Fiddler 调试服务。
成功:
localhost/UserRestService.svc/api/GetMembership/23
失败: localhost/UserRestService.svc/api/GetUserProfile/xyz@gmail.com
错误:[Fiddler] ReadResponse() 失败:服务器没有返回一个 对此请求的响应。服务器返回 0 个字节。
我无法理解这个错误。我用谷歌搜索并无法解决此错误。
请帮忙。
代码:
WCF 服务接口:
[OperationContract]
[WebGet(UriTemplate = "/api/GetUserProfile/{userName}",RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
// UserProfiles
UserProfile GetUserProfile(string userName);
提琴手原始请求
GET localhost:37181/UserRestService.svc/api/GetUserProfile/abc@gmail.com HTTP/1.1
Host: localhost:37181
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cookie: _gauges_unique_year=1; _gauges_unique=1; lang=auto; __RequestVerificationToken=XCXv18_vpGu9UO4wian60eLRZqUQi6_
【问题讨论】:
-
如果在服务代码中设置断点会发生什么?服务是否被调用?另外,看到了这个:stackoverflow.com/questions/9425288/…
-
@rmayer06:当我在服务上放置断点时,它会给出适当的响应。但最后,浏览器向我显示了上述错误。
-
@Zaki:我已经添加了代码...
-
在您的服务和返回 Web 服务之间发生了一些事情。也许是序列化错误?您是否有 MS 源代码,您可以在代码之后单步执行代码吗?
标签: c# asp.net wcf rest asp.net-web-api