我有一个非常愚蠢的问题,但由于某种原因,我无法在网上找到任何治疗方法或有关它的信息。
摘要:我不能将多个参数传递给 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) {
...
}
}
Global.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
提前感谢您的帮助!
PS我试图在查询字符串中对“&”进行HTML编码——没有效果。