Last post Apr 22, 2015 04:49 AM by Archer Wang
Apr 21, 2015 09:50 AM|AGodinho|LINK
I've been trying to fix a problem that I've but I honestly donno if it can be donne.
I want to use URL ReWrite with a session value.
I tryed with Global.asax but on Application_BeginRequest session doesn't exists yet. Also on Application_AcquireRequestState but I think it's too late for the ReWritePath. This is what I've:
void Application_AcquireRequestState(object sender, EventArgs e)
// && HttpContext.Current.Session["key"] != null
if (System.Web.HttpContext.Current.Session != null )
string fullOrigionalpath = Request.CurrentExecutionFilePath.ToLower();
HttpContext.Current.Session.Add("passei", fullOrigionalpath); // Works ok!
if (fullOrigionalpath.CompareTo("/default.aspx") == 0)
Apr 22, 2015 01:47 AM|Archer Wang|LINK
Thank you for your post. I think you could try below code.
About how to use HttpContext.RewritePath Method (String), please check the below link.
Hope this could be helpful to you.
Apr 22, 2015 03:46 AM|AGodinho|LINK
I had tryed this:
But it gives me a 404 ERROR, the ReWrite is completely ignored...
Like I thought, if I use this on Application_BeginRequest works perfectly:
string fullOrigionalpath = Request.Url.ToString();
Apr 22, 2015 04:49 AM|Archer Wang|LINK
As I know, Session is not accessed at Application_BeginRequest.
Above are two similar case abour rewrite url at Application_AcquireRequestState. It seems that we may not rewrite url at Application_AcquireRequestState.
So, I suggest that you could rewrite at Application_BeginRequest.