简体   繁体   中英

Adding a variable to routeconfig ASP.net

I am generating my routeconfig from a database.

I have a file combine.aspx which combines all data into a virtual webpage.

Right now the routing is working, however I have a problem.

I want the url to look like this:

www.domain.com/Home

This is working, however the combiner needs the pageId . How can I send this without showing it in the url? This is how the route is combined now:

 routes.MapPageRoute(
   page.pageName,
   url,
   "~/combine.aspx");

You can use this overload of MapPageRoute: RouteCollection.MapPageRoute Method (String, String, String, Boolean, RouteValueDictionary)

Like this:

routes.MapPageRoute(
    page.pageName,
    url,
    "~/combine.aspx"
    false,
    new{ pageId = page.pageId }//or whatever variable value you want to use
);

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