开发者

wildcarded httphandler with mvc no longer working

开发者 https://www.devze.com 2023-03-05 10:55 出处:网络
I have this &开发者_StackOverflow社区lt;add name=\"xxx\" verb=\"GET,POST,PUT\" path=\"xxx/*\" type=\"....\" />

I have this

      &开发者_StackOverflow社区lt;add name="xxx" verb="GET,POST,PUT" path="xxx/*" type="...." />

Ie any url that looks like xxx/anything should go to that handler. Now that this is cohosted in an MVC app it no longer works. It seems that I need some derivative of

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

but I cannot work out the correct incantation


has to be

public class XXXRouteHandler : IRouteHandler
{
    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        return new XxxHandler(); // the original http handler
    }
}

and

     var xxxroute = new Route("xxx/{*pathinfo}", new XXXRouteHAndler());
     routes.Add(xxxroute);

in RegisterRoutes

Correction: better is

            routes.IgnoreRoute("xxx/{*ignore}");
0

精彩评论

暂无评论...
验证码 换一张
取 消