开发者

How do I block access to files when using the System.Web.Routing.UrlRoutingModule?

I'm using the System.Web.Routing.UrlRoutingModule.

With that I'm writing:

routes.Add(new Route(@"cart/add", new RouteHandler("~/Order/CartAdd.ashx")));
routes.Add(new Route(@"cart/delete", new RouteHandler("~/Order/CartDelete.ashx")));
...

And I also have one route called:

routes.Add(new Route(@"{*ur开发者_Python百科l}", new RouteHandler("~/Error/PageNotFound.ashx")));

But if I go directy to /Order/CartAdd.ashx I never enter the routing. It goes directly to that handler. And if I go to /Order/ I get a 403.14 error.

How do I instead catch those urls with the routing?


In your route registration code, you can write something like this..

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.RouteExistingFiles = true;
        routes.IgnoreRoute("default.aspx");
        [...]

Which should force file requests through your routing rules.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜