|
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
|
|
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!
|
|
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!
|
|
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!
|
|
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!
|
|