+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Error when using IndexInternalPageHandler

Error when using IndexInternalPageHandler

4 posts, 0 answered
  1. Luc Baeten
    Luc Baeten avatar
    169 posts
    Registered:
    23 Sep 2005
    23 Nov 2010
    Link to this post
    Hello Sitefinity Team

    I want to convert a Sitefinity webpage to PDF. For this I use the HtmlToPdf converter. But to use this component I need to have the html content of the Sitefinity page.

    To get the html content I used the following script, based on IndexInternalPageHandler:

    string pdfBaseURL = UrlPath.ResolveUrl("~/Orders/PrintOrderList.aspx");
    StringWriter sw = new StringWriter();
    ICmsUrlContext context = UrlHelper.GetUrl(pdfBaseURL, true);
    CmsSiteMapNode node = context.GetSiteMapNode() as CmsSiteMapNode;
    ICmsPage page = node.GetCmsPage();
    IndexInternalPageHandler pageHandler = new IndexInternalPageHandler(sw, pdfBaseURL, page.ID, null);
    pageHandler.AppRelativeVirtualPath = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;
    HttpContext.Current.Server.Execute(pageHandler, sw, false);

    I am using the GetUrl function to get the pageID of the page I want to convert.. However on the call Server.Execute I get the exception 'Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.'.
    The page itself doesn't have any errors. 

    Is the used code to get the html content the correct way, and if yes please could you help me solve the error. If not how should I solve it in another way?

    regards
    Luc
  2. Luc Baeten
    Luc Baeten avatar
    169 posts
    Registered:
    23 Sep 2005
    02 Dec 2010
    Link to this post
    Hello Sitefinity Team

    Last week I defined this thread. Does someone have an idea how to solve this problem?

    Kind regards
    Luc
  3. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    03 Dec 2010
    Link to this post
    Hello Luc Baeten,

    Thank you for using our services.

    It seems that the problem is related to the one described in this blog post. Can you please try executing the last statement with true value for the last parameter.

    Kind regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Luc Baeten
    Luc Baeten avatar
    169 posts
    Registered:
    23 Sep 2005
    03 Dec 2010
    Link to this post
    Hello Radoslav

    With this information I was able to solve it. Thanks

    Regards
    Luc
Register for webinar
4 posts, 0 answered