Copied to clipboard

Flag this post as spam?

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


  • karen 186 posts 461 karma points
    Apr 15, 2015 @ 23:34
    karen
    0

    PdfMvcHelperExample not working

    I added thet 'PdfMvcHelperExample.cshtml' template, now trying to load the pdf, but I get this error;

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

    Compiler Error Message: CS0138: A using namespace directive can only be applied to namespaces; 'PdfHelper' is a type not a namespace

    Source Error:

     
    Line 1:  <?xml version="1.0" encoding="UTF-8" ?>
    Line 2:  @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    Line 3:  @using PdfHelper
    Line 4:  @{
    Line 5:      Layout = null;

    pdf.cshtml and pdfHelper.cshtml are in the app_data folder.

    The PDFRazorHelperExample.master works.

    Any ideas?

     

  • Johan Möller 83 posts 137 karma points
    Apr 23, 2015 @ 10:18
    Johan Möller
    0

    Did you solve this? I have the same problem.

  • Johan Möller 83 posts 137 karma points
    Apr 23, 2015 @ 10:48
    Johan Möller
    0

    My colleague Peter helped me with a solution.

    First remove @using PdfHelper in the example. Then add the following to PdfHelper.cshtml in App_Code.

    @functions
    {
        private static new HtmlHelper<object> Html
        {
            get { return ((WebViewPage)CurrentPage).Html; }
        }
    
        private static UrlHelper Url
        {
            get { return ((WebViewPage)CurrentPage).Url; }
        }
    }
    
  • karen 186 posts 461 karma points
    Apr 23, 2015 @ 22:53
    karen
    0

    no - haven't had a solution yet.

    will give this a try and let you know (fixing other issues atm).

    thank you!

     

Please Sign in or register to post replies

Write your reply to:

Draft