找到多个与请求匹配的操作:System.Net.Http.HttpResponseMessage

Multiple actions were found that match the request: System.Net.Http.HttpResponseMessage

我的路线在这里:

// Web API routes
config.MapHttpAttributeRoutes();

config.Routes.MapHttpRoute(
    name: "DefaultApi",
    routeTemplate: "api/{controller}/{id}",
    defaults: new { id = RouteParameter.Optional }
);

// Controllers with Actions
// To handle routes like `/api/VTRouting/route`
config.Routes.MapHttpRoute(
   name: "ControllerAndAction",
   routeTemplate: "api/{controller}/{action}/{id}",
   defaults: new { id = RouteParameter.Optional ,extension = RouteParameter.Optional }
);

我的 API 是:

[System.Web.Mvc.HttpPost]
[System.Web.Mvc.ActionName("san")]
public HttpResponseMessage san([FromBody]Login value)
{
   var result = db.SSI_Member_Registation.Where(c => c.InqID == value.userid && c.BirthDt == value.Password).FirstOrDefault();
   return Request.CreateResponse(HttpStatusCode.OK, result);
}

//// POST api/values
[System.Web.Mvc.HttpPost]
[System.Web.Mvc.ActionName("san1")]
public void Post([FromBody]string value)
{
}

我将参数作为 Json 传递,并将这些行 [![在此处输入图片描述][1]][1]

我做错了什么?

更改路线顺序:

// Web API routes
config.MapHttpAttributeRoutes();

// Controllers with Actions
// To handle routes like `/api/VTRouting/route`
config.Routes.MapHttpRoute(
   name: "ControllerAndAction",
   routeTemplate: "api/{controller}/{action}/{id}",
   defaults: new { id = RouteParameter.Optional ,extension = RouteParameter.Optional }
);

config.Routes.MapHttpRoute(
    name: "DefaultApi",
    routeTemplate: "api/{controller}/{id}",
    defaults: new { id = RouteParameter.Optional }
);

如果您先注册默认的,它将覆盖其余的。