SharePoint发布站点HTTPModule

时间:2010-11-24 13:12:04

标签: sharepoint-2007 redirect httpmodule url-rewriting

我为重定向目的编写了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但不适用于发布网站。 Page.PreInit不会针对发布网站触发。

请帮我解决这个问题!

我正在使用PreRequestHandlerExecut e,因为我需要会话对象和其他细节,否则我会使用BeginRequest

1 个答案:

答案 0 :(得分:0)

我通过将重定向代码移动到PreRequestHandlerExecute事件处理程序

来解决它