【发布时间】:2014-12-26 20:56:18
【问题描述】:
我使用 ASP .NET Web API 创建了一个 Web 服务。方法是:
[HttpGet]
[Route("service/{applicantUser}/{lastUpdate:datetime?}")]
public IHttpActionResult getService(String applicantUser, DateTime? lastUpdate = null){
// some stuff here
}
如果我这样调用WS:
http://myserver/api/service/myusername/2008-12-10
一切正常,我获得了正确的 json 文件。但如果我尝试添加时间:
http://myserver/api/service/myusername/2008-12-10T12:30:00
我得到错误404 - Bad Request
【问题讨论】:
-
此网址是否有效:
http://myserver/api/service/myusername/?lastUpdate=2008-12-10T12:30:00 -
哦,是的,它有效。但是,有什么办法可以避免 RPC 风格?
标签: c# asp.net web-services asp.net-web-api