Welcome Guest Search | Active Topics | Sign In | Register

Losing SessionState after render Options
Daniele
Posted: Sunday, September 8, 2013 5:38:48 PM
Rank: Member
Groups: Member

Joined: 11/15/2012
Posts: 16
Hi, i've the last version of dll.
When i call:

HttpContext.Current.Session["value"] = "hello";
ASPXToPDF1.RenderAsPDF(false);
ASPXToPDF1.AfterRender += new EventHandler(ASPXToPDF1_AfterRender);

into the void ASPXToPDF1_AfterRender(object sender, EventArgs e) the HttpContext.Current.Session["value"] is null

Why it losing the session?
How can i pass values to AfterRender method?

Thanks
dan
eo_support
Posted: Sunday, September 8, 2013 5:47:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

This is normal. AfterRender is called at very late stage of the page's life cycle, at which point the HTML rendering process has already finished and the session object has already been released.

If you just want to pass a value to the AfterRender method, you can just save that value as a member of your page class.

Thanks!
Daniele
Posted: Sunday, September 8, 2013 5:51:11 PM
Rank: Member
Groups: Member

Joined: 11/15/2012
Posts: 16
Hi, it's normal?
HttpContext.Current.Session in persistent in all application over pages postback and rendering. It's not normal that my session in equal to null!
eo_support
Posted: Sunday, September 8, 2013 5:58:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

It is normal. When a request is sent to ASP.NET, ASP.NET takes these steps to process the page:

1. Acquires session data;
2. Build your page object tree;
3. Render that object tree into HTML;
4. Release session data;
5. Send the result HTML to the client;

For almost all other ASP.NET controls, your code is called during step 2 and step 3, during those stage the session data is available to you. For ASPXToPDF, the AfterRender event is called between step 4 and step 5. During this state the session data has already been released and is no longer available.

Thanks!
Daniele
Posted: Sunday, September 8, 2013 6:00:19 PM
Rank: Member
Groups: Member

Joined: 11/15/2012
Posts: 16
Oh ok, thank you!
So i must temporaty save my session to a page variable and use it in the AfterRender method!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.