[英]ASP.NET WebAPI Custom route not getting hit, returning 404
我已经为控制器中的方法设置了此自定义路由:
[HttpPost, Route("imagconv/{format1}/to/{format2}")]
public HttpResponseMessage imagconv( [FromUri] string format1, [FromUri] string format2)
控制器上的路由为:
[RoutePrefix("convert")]
public class DocumentConvertController : ApiController
我想用这个例子在邮递员中称呼它:
http:// ...server... /convert/imageconv/psd/to/png
而不是得到结果,我得到了404错误。
这是我的RouteConfig中的内容:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
有谁知道为什么这不起作用? 这似乎很简单。 提前致谢!
这是路线定义中的错字,缺少“ e”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.