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.
精彩评论