1
votes

I made a folder called 'pages' in my asp web forms project. In this folder I have a lot of pages:

  • test.aspx
  • hello.aspx

When I open these pages in a browser I get:

  • www.domain.com/pages/test.aspx
  • www.domain.com/pages/hello.aspx

This is normal, I know. But what if I want to delete the /pages in the url and just show (without .aspx):

  • www.domain.com/test*.aspx*
  • www.domain.com/hello*.aspx*

I can do this by manually adding a new route (in RegisterRoutes() method) for each page but is there a way to do this dynamicly?

I found this question but I don't know if I can use it for this problem. WebForms custom / dynamic routing

1

1 Answers

1
votes

Try something like this, not sure if that will do it. But you could always just put your pages in the root directory. I think this would work.

Source Link: http://msdn.microsoft.com/en-us/library/vstudio/cc668177(v=vs.100).aspx

routes.MapPageRoute("PageRoute","{page}", "~/pages/{page}.aspx");

Not sure if that's what you were looking for, this way you can just do something like:

Response.RedirectToRoute("PageRoute", new { page = "test" });