I am trying to use session in OnBeginRequest but not work.
Other queestion posted answers shows that its works on different event handlers, but i need session to work specifically for OnBeginRequest
Because, current browser url will be present only in OnBeginRequest, which i can rewrite, when there is a redirection, if it is some other event handler, I will get all urls of the page in the HttpContext.Current.Request.Url. But i need only browser url in HttpContext.Current.Request.Url.
void OnBeginRequest(object sender, EventArgs e)
{
HttpApplication appObject = (HttpApplication)sender;
HttpContext contextObject = appObject.Context;
string rpath = HttpContext.Current.Request.Url.ToString();
contextObject.Session["Session"] = "Assigning here"; //But after assigning it is null
string rewritestr = HttpContext.Current.Request.Url.AbsolutePath.Replace(subFolName, "");
rewritestr = rewritestr.Replace("//", "/");
contextObject.RewritePath(rewritestr);
}
How we can assign this? and use the same session when we redirect to another pages and execution reach here.