【发布时间】:2011-10-05 01:13:20
【问题描述】:
我有一个非常愚蠢的问题,但由于某种原因,我无法在网上找到任何解决方法或相关信息。
总结:我不能将多个参数传递给 WebGet 方法。如果我这样做了,服务器会返回 HTTP 500 错误并且该方法不会执行。我的代码和请求如下。
[ServiceContract]
public class WebmailAPI {
...
[WebGet(UriTemplate= "Webmail?messagetype={messageType}&unreadonly={unreadOnly}&skip={skip}&take={take}")]
public void Get(MessageType messageType, bool unreadOnly, int skip, int take) {
...
}
}
全球.ASAX.CS: routes.SetDefaultHttpConfiguration(new WebApiConfiguration() { EnableHelpPage = true, EnableTestClient = true }); RouteTable.Routes.MapServiceRoute("api/");
这个请求执行得很好: http://localhost:9000/api/Webmail/?messagetype=1
这个返回500错误:
http://localhost:9000/api/Webmail/?messagetype=1&unreadonly=0&skip=0&take=100
信息: VS2010 SP1 + ASP.NET 4 + Entity Framework 2001 年 6 月 CTP + 最新的 WebAPI
提前感谢您的帮助!
附:我尝试在查询字符串中对“&”进行 HTML 编码——没有效果。
【问题讨论】:
标签: wcf wcf-web-api