2

我编写了一个自定义 url 重写 http 模块,该模块在集成托管管道应用程序池中完美运行。

但是当我把它转到经典时,它就停止工作了。

protected virtual void BaseModuleRewriter_AuthorizeRequest(
            object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication) sender;
            Rewrite(app.Request.Path, app);
        }

        protected void Rewrite(string requestedPath,HttpApplication app)
        {
            if (requestedPath.IndexOf('.') == -1)
            {

                Page page =PageManager.GetPageByAlias(requestedPath.EndsWith("/") ? requestedPath.Substring(0, requestedPath.Length - 1) : requestedPath);
                if (page != null)
                {
                    app.Context.RewritePath(page.RelativeUrl == null ? "/Default.aspx?PageId=" + page.Serial : page.RelativeUrl.Substring(1), false);
                    //app.Session["ThisPage"] = page;
                    app.Response.StatusCode = 200;
                }
                else
                {
                    app.Response.StatusCode = 404; 
                }

            }
        }

我应该解释一下“Page”是一个具有“RelativeUrl”和“AliasAddress”属性的数据库实体。任何想法有什么问题?

4

0 回答 0