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
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
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.