0

I have an asp.net application and I need to do the following:

Assume that i have a page called page1.aspx, what i need is that:

when the user requests page1.aspx?id=1 to be redirected to http://myapp/books

when the user requests page1.aspx?id=2 to be redirected to http://myapp/movies

books and movies are virtual paths and I don't want to do this using web.config (rewite section) since this should be dynamic.

any help would be appreciated

Alex
  • 5,971
  • 11
  • 42
  • 80

1 Answers1

0

Build an HttpModule and in context_BeginRequest you can get the current URL . Later conditionally redirect to the new URL.

public class RedirectionModule : IHttpModule
{
    void context_BeginRequest(object sender, EventArgs e)
    {

      // get current url
      // conditionally redirect it
    }
}

[Edit] for SEO URL rewriting ASP.NET please refer SEO URL rewriting ASP.NET page

Community
  • 1
  • 1
Jomy John
  • 6,308
  • 4
  • 28
  • 32