我有一个asp.net应用程序,需要执行以下操作:
假设我有一个名为page1.aspx的页面,我需要的是:
当用户请求将page1.aspx?id=1重定向到http://myapp/books时
当用户请求将page1.aspx?id=2重定向到http://myapp/movies时
书籍和电影都是虚拟路径,我不想使用web.config (rewite section)来实现这一点,因为这应该是动态的。
任何帮助都将不胜感激
发布于 2012-10-12 16:59:37
构建一个HttpModule,在context_BeginRequest中你可以获得当前的网址。稍后,有条件地重定向到新的URL。
public class RedirectionModule : IHttpModule
{
void context_BeginRequest(object sender, EventArgs e)
{
// get current url
// conditionally redirect it
}
}编辑为SEO重写ASP.NET请参考SEO URL rewriting ASP.NET页面
https://stackoverflow.com/questions/12855356
复制相似问题