Url rewriting module doesn't work on classic pipline in IIS 7.5

507 views Asked by At

I wrote a custom url rewriting http module that's work perfectly in Integrated managed pipline app pool.

but when I turn it to Classic, it stops working.

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; 
                }

            }
        }

I should explain that "Page" is a database entity that has "RelativeUrl" and "AliasAddress" property. any Idea what's wrong?

0

There are 0 answers