c# - WCF Restful 服务不向 Web 客户端发送响应

标签 c# asp.net wcf rest asp.net-web-api

我在我的网络应用程序中使用 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/

相关文章:

c# - asp.net c# 扫描应用程序代码重复 - 实用程序

c# - Umbraco 中的母版页

.net - WCF JSON SSL 配置

c# - IIS 中的 WCF,http 基本身份验证 - Windows 用户 "security"含义

.net - 实现 WCF 数据服务 OData 操作

c# - 文件中其他十六进制条目的值相同

c# - 尝试在 DocumentDB 中创建文档时获取 "A task was cancelled"

c# - 在 C# 中使用 SSL (https) 使用 Web 服务

c# - 可访问性、属性类型不一致

javascript - 使用 Mootools、jQuery 或 Ajax 查找城市和州的 ASP.NET Javascript 邮政编码