需要帮忙。
我有 2 个控制器:
// POST (Single SMS)
[ActionName("AddSMS")]
public HttpResponseMessage Post(MySMS singleSMS)
{
try
{
SMS_Repository.Add(singleSMS);
return Request.CreateResponse<MySMS>(HttpStatusCode.Created, singleSMS);
}
catch (Exception)
{
return Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, "Error");
}
}
// POST (Collection of SMSes)
[ActionName("AddSMSCollection")]
public HttpResponseMessage Post(List<MySMS> smses)
{
try
{
SMS_Repository.Add(smses);
return Request.CreateResponse<List<MySMS>>(HttpStatusCode.Created, smses);
}
catch (Exception)
{
return Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, "errorus");
}
}
和路线:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional, action = RouteParameter.Optional }
现在。如果我这样发送请求:
本地主机:25856/api/sms/AddSMSCollection
有用
是否可以调整路由以便我可以使用localhost:25856/api/sms并且没有找到与请求错误匹配的多个操作?
对不起,我的英语不好..