我在我的网络应用程序中使用 MVC5、WebAPI、WCF Restful 服务。
当我朗读 WCF Restful 服务时,我得到了不同的回应。有些服务会给我适当的回应,有些则不会。我正在我的机器上运行这个应用程序。
我使用 Fiddler 来调试服务。
成功:
localhost/UserRestService.svc/api/GetMembership/23
失败: localhost/UserRestService.svc/api/GetUserProfile/xyz@gmail.com
Error: [Fiddler] ReadResponse() failed: The server did not return a response for this request. Server returned 0 bytes.
我无法理解这个错误。我用谷歌搜索,但无法解决此错误。
请帮忙。
代码:
WCF 服务接口(interface):
[OperationContract]
[WebGet(UriTemplate = "/api/GetUserProfile/{userName}",RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
// UserProfiles
UserProfile GetUserProfile(string userName);
Fiddler 原始请求
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_
最佳答案
您需要对 @ 符号进行转义,它在 URI 中具有保留意义。
关于c# - WCF Restful 服务不向 Web 客户端发送响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21552545/