开发者

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

开发者 https://www.devze.com 2023-02-20 19:23 出处:网络
I have a Global.ascx and I wrote a simple url writer module : void Application_BeginRequest(object sender, EventArgs e)

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 a开发者_运维技巧lso.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消