我已经编写了一个用于重定向的HTTPModule,并安装在GAC中,并在根web.config文件中引用。它在团队站点上工作得很好。
我使用PreRequestHandlerExecute查看请求是否为页面,并调用
public void Init(HttpApplication context)
{
this.app = context;
this.app.PreRequestHandlerExecute += new EventHandler(Application_PreRequestHandlerExecute);
}
void Application_PreRequestHandlerExecute(object source, EventArgs e)
{
Page page = HttpContext.Current.CurrentHandler as Page;
if (page != null)
{
page.PreInit += new EventHandler(Perform_Redirection);
}
}在Perform_Redirection方法中,我做了重定向的事情。
void Perform_Redirection(object source, EventArgs e)
{
//logic goes here for redirection
}上面的代码适用于Teamsites,但不适用于Publishing sites。Page.PreInit不会为发布网站而触发。
请帮我解决这个问题!
我使用PreRequestHandlerExecute,因为我需要session对象和其他细节,否则我会使用BeginRequest。
发布于 2011-05-27 20:38:15
我通过将重定向代码移到PreRequestHandlerExecute事件处理程序中解决了这个问题
https://stackoverflow.com/questions/4267145
复制相似问题