kamiar3001
kamiar3001

Reputation: 2686

how I can use Global.asax and implement handler for it?

I have a Global.ascx and I wrote a simple url writer module :

void Application_BeginRequest(object sender, EventArgs e)
{
    try
    {
        string strPath = Context.Request.Url.AbsoluteUri;
        string[] sections = strPath.Split('/');
        int len = sections.Length;
        string strExtention = sections[len - 1].Split('.')[1];
        if (strExtention.ToLower().TrimEnd().Equals("xml"))
        {
            if (sections[len - 2].Equals("ATM"))
                Context.RewritePath("~/Include/XML Files/Orders/TMP/" + sections[len - 1]);
            else
                Context.RewritePath("~/Include/XML Files/Orders/" + sections[len - 1]);
        }
    }
    catch
    {
    }
}

it works locally but it dosen't work in the host how I can implement handler for this ?

Server.Transfer doesn't work also.

Upvotes: 1

Views: 294

Answers (1)

m.edmondson
m.edmondson

Reputation: 30922

You are correct with going down the route of a module. However instead of Context.RewritePath() use Response.Redirect(), this simply returns a 3xx message to the browser which will redirect its request to the new URL. This should work wherever it's implemented.

Upvotes: 1

Related Questions