开发者

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

开发者 https://www.devze.com 2022-12-17 14:20 出处:网络
I\'m using the System.Web.Routing.UrlRoutingModule. With that I\'m writing: routes.Add(new Route(@\"cart/add\", new RouteHandler(\"~/Order/CartAdd.ashx\")));

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

精彩评论

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