HttpHandler does not rewrite

I am writing a simple HttpHandler to rewrite a URL, but I am pushing a brick wall.

I created an HttpHandler class that is just simple to check:

public class HttpHandler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.RewritePath("default.aspx", false);
        //Rewriter.Rewrite(context);
    }

    public bool IsReusable
    {
        get
        {
            return true;
        }
    }
}

Then I have the following verb in the web.config file:

<httpHandlers>
  <add verb="*" path="*" type="Tizma.CMS.Runtime.HttpHandler"/>
</httpHandlers>

Basically, I want the entire incoming URL to go through this rewriter. When I run this, ProcessRequest starts, but RewritePath never gets the default.aspx value.

Please note that this is just a test, and as a result, default.aspx will be transmitted by the query string along the strings? pageid = 2 I just wanted to find out how httphandlers worked.

What am I doing wrong?

+3
source share
4 answers

- RewritePath() - . , , RewritePath() .

RewritePath (, BeginRequest - , CacheModule ), , , , HttpModule .

+12

HttpHandler, Web Forms (System.Web.UI.Page IHttpHandler). web.config

<add path="*.aspx" verb="*" type="System.Web.UI.PageHandlerFactory" validate="true"/>

URL- default.aspx , web.config , HttpHandler URL-, default.aspx.

HttpModule, , BeginRequest. HttpModule .

+2

? RewritePath , URL- . default.aspx, .

0

Source: https://habr.com/ru/post/1715779/


All Articles