Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andreas Schønau 9 posts 79 karma points
    Aug 10, 2016 @ 10:54
    Andreas Schønau
    0

    PdfMvcHelperExample.cshtml resulting in 'Object reference not set to an instance of an object 'Error

    Hi

    I have installed PDF Creator on UaaS, and I am able to create PDF documents using the old-style .master templates.

    I would however like to use a .cshtml template and have hence found the Example-MVC-templates-for-PDF-Creator.zip file at: http://our.umbraco.org/FileDownload?id=7068

    The non-helper based templates work fine, but when I try to use the helper template I have two problems

    1. The template includes '@using PdfHelper' which will not compile. I can take it out and then i can un the website in debug mode, but

    2. If I remove the '@using PdfHelper' line I get an 'Object reference not set to an instance of an object' Error tied to the first call of the helper methods:

    enter image description here

    Any ideas?

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Aug 12, 2016 @ 07:58
    Darren Ferguson
    0

    Hi Andreas,

    To me it looks like the web.config in your /Views folder doesn't contain the references required to access @Html...

    Could you post that file? and I'll compare to my working example.

    Thanks.

  • Andreas Schønau 9 posts 79 karma points
    Aug 12, 2016 @ 08:12
    Andreas Schønau
    0

    Sure:

    Wrong file...

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Aug 12, 2016 @ 09:01
    Darren Ferguson
    0

    This looks like the web.config from the root of your application - i need to take a look at the one in the Views folder.

  • Andreas Schønau 9 posts 79 karma points
    Aug 12, 2016 @ 09:04
    Andreas Schønau
    0

    Sorry, here it is:

    <?xml version="1.0"?>
    

    <!--
        Enabling request validation in view pages would cause validation to occur
        after the input has already been processed by the controller. By default
        MVC performs request validation before a controller processes the input.
        To change this behavior apply the ValidateInputAttribute to a
        controller or action.
    -->
    <pages
        validateRequest="false"
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <controls>
        <add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
      </controls>
    </pages>
    

    <handlers>
      <remove name="BlockViewHandler"/>
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
    

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Aug 12, 2016 @ 10:34
    Darren Ferguson
    0

    Could you try add:

    @using System.Web.Mvc

    To the top of the file.

    Thanks. Darren.

  • Andreas Schønau 9 posts 79 karma points
    Aug 12, 2016 @ 13:55
    Andreas Schønau
    0

    Hi Darren

    Thanks, whis may be part of the solution, but there are still a couple of issues.

    1. I no longer seem to have access to the @Model object - which is not critical to me.

    2. I seem to get the same error (see below) everytime @Html.Raw is used:

    enter image description here

    Best regards, Andreas

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Aug 15, 2016 @ 08:08
    Darren Ferguson
    0

    Hi Andreas - Could you post the whole stack trace please. I'm on holiday/vacation this week, so my response may not be so prompt.

  • Andreas Schønau 9 posts 79 karma points
    Aug 15, 2016 @ 11:21
    Andreas Schønau
    0

    Hi Darren

    Sure, here it is:

    [NullReferenceException: Object reference not set to an instance of an object.] ASP.PdfHelper.

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Aug 18, 2016 @ 15:17
    Darren Ferguson
    0

    Could you send me your PdfHelper.cshtml to my email address darren at moriyama.co.uk?

Please Sign in or register to post replies

Write your reply to:

Draft