Welcome Guest Search | Active Topics | Sign In | Register

Null Reference of MVCToPDF in Async Action Options
NickT
Posted: Thursday, September 12, 2024 9:43:24 AM
Rank: Newbie
Groups: Member

Joined: 9/11/2024
Posts: 1
After having consistency issues when rendering a PDF from an async task, I wanted to try manually triggering the conversion as shown here. However, I'm encountering the same null reference error mentioned in this post, even though I'm accessing MVCToPDF within the controller action as seen in a reply to this post.

I'm using v20.2.90. Here's code I'm using to test this functionality with:

Code: C#
[CombinedColumnPrintLayout]
[RenderAsPDF(ResultAsDownload = true, AutoFormsAuthentication = true, AutoConvert = false)]
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "None", Location = OutputCacheLocation.Client)]
public async Task<ActionResult> TestDownload(long id)
{

    HtmlToPdf.Options.OutputArea = new RectangleF(.0f, .2f, 8.5f, 10.6f);
    HtmlToPdf.Options.FooterHtmlFormat = "";

    var summary = await _mediator.Send(new SampleGet.Query(id));

    MVCToPDF.RenderAsPDF();

    return View();
}


Any ideas why MVCToPDF would be null here?
eo_support
Posted: Thursday, September 12, 2024 9:53:00 AM
Rank: Administration
Groups: Administration

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

Please try the current version and see if it resolves the issue for you. Our older version does not support async tasks. So you will always run into problems.

The second link you posted is not the same as the NullReferenceException you received. That link is about getting NullReferenceException inside OnResultExecuting, which is expected. However that is not your case, your case is inside the action method as you have correctly stated.

If you continue to have problems with the current version, please try to isolate the problem into a test project and send the test project to us. Once we have that we will look into it immediately. See here for more information on how to send test project to us:

https://www.essentialobjects.com/forum/test_project.aspx

Thanks!


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.