public class IncidentController : ApiController
{
[HttpPost]
[ActionName("Incident")]
public async Task<IEnumerable<IncidentModel>> GetAsync([FromBody] IncidentQuery incidentQuery)
{
}
[HttpPost]
[ActionName("ProblemRecord")]
public async Task<IEnumerable<ProblemRecordModel>> GetAsync([FromBody] ProblemRecordQuery problemRecordQuery, ILog log)
{
}
}
我有来自同一个控制器的多个HttpPost方法,我定义了ActionName属性并添加了路由。
config.Routes.MapHttpRoute(
name: "Incident",
routeTemplate: "api/incident",
defaults: new { controller = "Incident" });
config.Routes.MapHttpRoute(
name: "ProblemRecord",
routeTemplate: "api/incident",
defaults: new { controller = "Incident" });
Context类仍抛出异常。有人可以解释我如何克服这个问题。我有两个方法具有相同的MethodName和HttpPost属性。
Restful webservice的新功能。请帮忙