SharePoint 发布网站 HTTPModule
我已经编写了一个用于重定向的 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
}
上面的代码适用于团队站点,但不适用于发布站点。 Page.PreInit
不会针对发布网站触发。
请帮我解决这个问题!
我正在使用 PreRequestHandlerExecut
e,因为我需要会话对象和其他详细信息,否则我会使用 BeginRequest
。
I have written an HTTPModule
for the redirection purpose and installed in GAC and referenced in root web.config
file. It is working for Team sites very well.
I am using PreRequestHandlerExecute
to see the request is page or not and calling
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);
}
}
and in the Perform_Redirection
method I am doing the redirection stuff.
void Perform_Redirection(object source, EventArgs e)
{
//logic goes here for redirection
}
The above code working fine for Teamsites but not for Publishing sites. The Page.PreInit
is not firing for publishing sites.
Please help me to solve this problem!
I am using PreRequestHandlerExecut
e, because I need session object and other details otherwise I would have used BeginRequest
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过将重定向代码移动到 PreRequestHandlerExecute 事件处理程序中解决了这个问题
I solved it by moving the redirection code into the PreRequestHandlerExecute event handler