Welcome Guest Search | Active Topics | Sign In | Register

Session No Longer Valid Error (only on server) Options
speartek
Posted: Tuesday, June 19, 2012 3:12:46 PM
Rank: Newbie
Groups: Member

Joined: 6/14/2012
Posts: 5
Everything is working fine locally, but when moving to a server, exceptions are thrown.

Pretty clueless as to what may be the issue here, been getting this error.

Code: C#
ExceptionId: 20120619_14504419_pgande. Handled Error from Global.asax:Application_Error
InnerException: EO.Pdf.Internal.ky: This session is no longer valid. If you wish to reuse the session later. please consider calling GetCookies to retain the session cookies. then reuse these cookies through HtmlToPdfOptions.Cookies with another session.
   at EO.Pdf.Internal.ll.a(a A_0)
   at EO.Pdf.Internal.ll.a(cp A_0)
   at EO.Pdf.HtmlToPdfSession.Dispose()
   at EO.Pdf.HtmlToPdf.ConvertHtml(String html. PdfDocument doc. HtmlToPdfOptions options)
   at EO.Pdf.HtmlToPdf.ConvertHtml(String html. PdfDocument doc)
   at EzTech.Web.pge.PrintPdf.Page_Load(Object sender. EventArgs e)
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp. Object o. Object t. EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender. EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint. Boolean includeStagesAfterAsyncPoint)
StackTrace:    at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint. Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint. Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.pge_printpdf_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\d1879b19\180ab2b7\App_Web_0l3w1sai.1.cs:line 0
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step. Boolean& completedSynchronously)
URL: myserver.com/pge/PrintPdf.aspx?div=DeAnza&dis=Cupertino&map=3280&plat=J7&cc=60010&emplId=97&empl=staelens. mark&date=6/6/2012
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
, ASP.Application_Error(),246, STVM-IIS9$ on STVM-IIS9, Error


Code: C#
protected void Page_Load(object sender, EventArgs e)
        {   

            WorkingDir = Request.ServerVariables["APPL_PHYSICAL_PATH"];
            PdfDocument doc = new PdfDocument();

            SetPdf();

			
            // Set landscape
            HtmlToPdf.Options.PageSize = new System.Drawing.SizeF(
                                         PdfPageSizes.A4.Height, PdfPageSizes.A4.Width);
            // Set margins to .5
            EO.Pdf.HtmlToPdf.Options.OutputArea = new RectangleF(0.25f, 0.25f, 11f, 8.5f);

            foreach (var log in CurrentPdf.LeakLogs)
            {
                CurrentPdf.CurrentDate = log.StartDate.ToString("MM/dd/yyy");
                CurrentPdf.CurrentLeakLog = log;
                var html = GetPdfHtml();
                HtmlToPdf.ConvertHtml(html, doc);
            }

            HttpResponse response = HttpContext.Current.Response;
            response.Clear();
            response.ClearHeaders();
            response.ContentType = "application/pdf";

            doc.Save(response.OutputStream);

            Response.End();
        }


Any help is appreciated.
speartek
Posted: Tuesday, June 19, 2012 3:38:15 PM
Rank: Newbie
Groups: Member

Joined: 6/14/2012
Posts: 5
Giving the application admin permissions fixed this, but a more helpful error would be appreciated.
eo_support
Posted: Tuesday, June 19, 2012 3:45:15 PM
Rank: Administration
Groups: Administration

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

Thanks for the update. We do not know how permission issue translates into this message yet. We will investigate and once we identify the exact scenario we will see if we can give a more accurate error message.

As to the license key ----- we want to be absolutely clear that you get the message: If you post your license key again anywhere publically your license will be immediately revoked and your key will become invalid and no refund will be given. You are required to put reasonable effort to ensure the license key is not being reused by any other party per our license agreement. So we will not tolerate such reckless behavior on your part again.

Thanks
speartek
Posted: Tuesday, June 19, 2012 4:07:24 PM
Rank: Newbie
Groups: Member

Joined: 6/14/2012
Posts: 5
I apologize for the oversight, I can assure you it will not happen again.

As for the issue at hand, it is not resolved.

I know giving the web application admin permissions resolved the issue, but I cannot give the web application admin permissions permanently.

From what I've gathered from another post is the dll is using the systems folder. The IIS user has full trust levels, and this issue persists. It is not reasonable for me to give permissions for the systems folder to the IIS user.

Do you have any suggestions or known workarounds?
eo_support
Posted: Tuesday, June 19, 2012 4:49:06 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Yes. I understand the issue is not resolved. We are investigating it and we will reply again if we find anything or if we need additional information from you. The product needs unmanaged permission (thus full trust) to work but it does not suppose to require admin permissions. Normally it does need read permission to system folder --- but I believe a "fall back" mechanism was implemented when that was not granted. So it supposes to work in that case as well --- in any case, it should at least give a more accurate message to clearly indicate which step fails if the fall back path fails too.

Thanks
speartek
Posted: Wednesday, June 20, 2012 12:00:42 PM
Rank: Newbie
Groups: Member

Joined: 6/14/2012
Posts: 5
I've been trying countless workarounds, and am finding very erratic behavior.

One fix will work a few times, and then the same error will occur.

The error is occurring on HtmlToPdfSession.Dispose(), what is this being used for underneath?

Edit:

Fixes seem to work the first time, but after this the same error occurs.

I've created static html strings and the Pdf is generated with no problems.

I then changed my code creating the html.
Code: C#
var templateContent = String.Empty;

            using (StreamReader sr = new StreamReader(WorkingDir + "/pge/PdfTemplate.cshtml"))
            {
                String line;
                while ((line = sr.ReadLine()) != null)
                {
                    templateContent += line;
                }
            }
            return Razor.Parse(template, CurrentPdf);


Instead of using streamreader to read the file containing the Razor template, I hardcoded it in.

Again the Pdf was generated once, and failed after that.

Finally I changed the options being set from the code in my original post to:
Code: C#
var options = new HtmlToPdfOptions();
            // Set landscape
            options.PageSize = new System.Drawing.SizeF(
                                         PdfPageSizes.A4.Height, PdfPageSizes.A4.Width);
            // Set margins to .5
            options.OutputArea = new RectangleF(0.25f, 0.25f, 11f, 8.5f);

            // Draw header
            options.HeaderHtmlFormat = @" 
                    <div style='font-size: 12px; font-family: Arial; color: #3A3A3A;'>
		                <p style='float: left;'>" + DateTime.Now.ToString("MM/dd/yyyy") + @"</p>
		       
	                </div>
                ";

            foreach (var log in CurrentPdf.LeakLogs)
            {
                CurrentPdf.CurrentDate = log.StartDate.ToString("MM/dd/yyy");
                CurrentPdf.CurrentLeakLog = log;
                var html = GetPdfHtml();
                HtmlToPdf.ConvertHtml(html, doc, options);
            }


Again all of these problems are irrelevant locally, where everything works fine always.

Also, if I run the application as an admin user, none of these problems persist, and I can open as many Pdfs as desired.

There is a login session for the site, but from my understanding the use of the HtmlToPdfSession is not a requirement. Am I wrong about this?

eo_support
Posted: Wednesday, June 20, 2012 2:49:14 PM
Rank: Administration
Groups: Administration

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

ConvertUrl/ConvertHtml creates a new HtmlToPdfSession and dispose it immediately after the conversion is done. So it still comes down to HtmlToPdfSession object. There got to be some issue with that object somewhere, please give us a little bit more time so that we can get to the bottom of this.

Thanks!
eo_support
Posted: Thursday, June 21, 2012 12:00:29 AM
Rank: Administration
Groups: Administration

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

We MAY have found the root cause of this. We were able to reproduce and fix the problem. Please download the new build from our download page (DLL version 4.0.18.2) and see if it fixes the problem for you.

Thanks!
speartek
Posted: Thursday, June 21, 2012 11:39:35 AM
Rank: Newbie
Groups: Member

Joined: 6/14/2012
Posts: 5
This release has fixed the problem.

Everything is working as expected; thank you for the help.
eo_support
Posted: Thursday, June 21, 2012 3:12:28 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Great! Thank you very much for confirming the fix!


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.