简体   繁体   English

ASP.NET WebAPI自定义路由未获得成功,返回404

[英]ASP.NET WebAPI Custom route not getting hit, returning 404

I have setup this custom route for a method in a controller: 我已经为控制器中的方法设置了此自定义路由:

[HttpPost, Route("imagconv/{format1}/to/{format2}")]
public HttpResponseMessage imagconv( [FromUri] string format1, [FromUri] string format2)

The route on the controller is: 控制器上的路由为:

[RoutePrefix("convert")]
public class DocumentConvertController : ApiController

And I am trying to call it in Postman with this example: 我想用这个例子在邮递员中称呼它:

http:// ...server... /convert/imageconv/psd/to/png

And instead of getting the result, I am getting a 404 error. 而不是得到结果,我得到了404错误。

Here is what is in my RouteConfig: 这是我的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 }
        );
    }

Does anyone know why this is not working? 有谁知道为什么这不起作用? This seems straightforward. 这似乎很简单。 Thanks in advance! 提前致谢!

这是路线定义中的错字,缺少“ e”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM