简体   繁体   中英

asp.net routing on homepage

When using routing (asp.net webforms) I want to setup a home route so I can browse articles on the frontpage like this

domain.com domain.com/1 domain.com/2 domain.com/3

I have no idea how to setup this routing because ~/ isn't accepted in the route. I tried http://www.domain.com/home/1 which works fine but is less nice ofcourse.

When I do it like this it work's fine but not on the homepage because it's looking for a pageindex which is ofcourse 'Default.aspx':

            routes.Add(
            "Home",
            new Route("{PageIndex}", new review.Routing.HomeRouteHandler())
        );

Any ideas on this, maybe im missing something here!

Thanks!

I don't know much about ASP.NET routing, but this article may help:

http://haacked.com/archive/2008/12/15/redirect-routes-and-other-fun-with-routing-and-lambdas.aspx

Use a trailing slash instead (It works for me anyway)

routes.Add(
            "Home",
            new Route("{PageIndex}/", new review.Routing.HomeRouteHandler())
        );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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