0

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.

SmartestVEGA
  • 8,415
  • 26
  • 86
  • 139
  • Possible duplicate of [Session not available in IHttpModule](http://stackoverflow.com/questions/21155567/session-not-available-in-ihttpmodule) – Craig W. Mar 14 '17 at 15:43
  • I need it specifically in OnBeginRequest , the above thread shows it works in different event handlers – SmartestVEGA Mar 14 '17 at 15:47

0 Answers0