Copied to clipboard

Flag this post as spam?

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


  • Ole Martin Bakke 112 posts 624 karma points
    Apr 11, 2016 @ 09:16
    Ole Martin Bakke
    0

    Error loading MacroEngine script (file: NewsletterSubscribe.cshtml)

    Hi, In Umbraco 7.4.1 we get an error loaing NewsletterSubscribe.cshtml. This happens even if we remove all the code from the file. I suspect that the macro parameter type "Newletter Studio Mailing List Picker" depends in the Microsoft.Web.Helpers.dll file which was removed i Umbraco 7.3.0. I have tried copying the file back, but that totally crashed the Umbraco site. I get the following stack trace in my log file:

    2016-04-11 11:01:32,827 [P10908/D3/T29] WARN umbraco.macro - Error loading MacroEngine script (file: NewsletterSubscribe.cshtml, Type: ''. Exception: System.Web.HttpCompileException (0x80004005): :****\AppWebnewslettersubscribe.cshtml.70df5e80.ycfpmb0_.0.cs(24): error CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'Microsoft.Web' (are you missing an assembly reference?) at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) at System.Web.WebPages.BuildManagerWrapper.CreateInstanceOfType[T](String virtualPath) at System.Web.WebPages.VirtualPathFactoryExtensions.CreateInstance[T](IVirtualPathFactory factory, String virtualPath) at System.Web.WebPages.VirtualPathFactoryManager.CreateInstanceOfType[T](String virtualPath) at System.Web.WebPages.VirtualPathFactoryExtensions.CreateInstance[T](IVirtualPathFactory factory, String virtualPath) at System.Web.WebPages.WebPageBase.CreateInstanceFromVirtualPath(String virtualPath, IVirtualPathFactory virtualPathFactory) at umbraco.MacroEngines.RazorMacroEngine.CompileAndInstantiate(String virtualPath) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage) at umbraco.macro.loadMacroScript(MacroModel macro) at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Apr 13, 2016 @ 09:22
    Markus Johansson
    0

    Hi!

    Thanks for sharing this!

    We need to take some time to try to figure out why but could it just be that we have some old using-references in the .cshtml-file that we ship? Do you mind having a look at that?

  • Ole Martin Bakke 112 posts 624 karma points
    Apr 13, 2016 @ 09:54
    Ole Martin Bakke
    0

    Ok, having another look at it, this is not an issue with Newsletter Studio. It seems like Umbraco has an issue viewing macroscripts. Seems like changing this to a partial macro will do the trick. I'll also check the issue-tracker to see if this issue is reported or fixed.

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Apr 18, 2016 @ 09:45
    Markus Johansson
    100

    Hi!

    Thanks for the heads up!

    We'll have a look to see if we can ship with a partial in the future.

    // m

  • Matthew Kirschner 323 posts 611 karma points
    Apr 18, 2016 @ 17:58
    Matthew Kirschner
    0

    Hello, Ole.

    I had the same issue a week ago and wound up creating the macro partial myself.

    Here it is if you haven't already gotten around to it. FYI, the markup is using the Foundation grid framework and Font Awesome.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @{
        var showThankYou = false;
        var error = "";
    
        if (Request.Form["action"] != null && Request.Form["action"] == "subscribe" && Request.Form["txtEmail"] != "")
        {
            var txtEmail = Request.Form["txtEmail"];
    
            if (NewsletterStudio.Api.IsValidEmail(txtEmail))
            {
                // Trying to get the subscriptionId from Macro-parameter.
                var subscriptionId = (Model.MacroParameters["SubscriptionId"] != null) ? Convert.ToInt32(Model.MacroParameters["SubscriptionId"]) : 0;
    
                // Adding subscriber
                var success = (subscriptionId != 0) ? NewsletterStudio.Api.Subscribe(txtEmail, subscriptionId) : NewsletterStudio.Api.Subscribe(txtEmail);
    
                showThankYou = true;
            }
            else
            {
                error = "* Please enter a valid e-mail";
            }
        }
    }
    
    @if (!showThankYou)
    {
        <form method="post" action="@Request.Url" style="max-width: 420px;">
            <input type="hidden" name="action" value="subscribe"/>
            <div class="row collapse">
                <div class="small-9 columns">
                    <input type="text" name="txtEmail" id="txtEmail" placeholder="My Email Address"/>
                </div>
                <div class="small-3 columns">
                    <button type="submit" id="btnSubmit" class="button postfix">Subscribe</button>
                </div>
            </div>
            <div style="color: Red">@error</div>
        </form>
    }
    else
    {
        <p class="panel success">
            <i class="fa fa-thumbs-up"></i> You have successfully subscribed to the Office of Research Newsletter.
        </p>
    }
    
  • Ole Martin Bakke 112 posts 624 karma points
    Apr 19, 2016 @ 06:16
    Ole Martin Bakke
    0

    Thanks, Matthew. We've already got this up and running, but this is nice to have if others should have the same issue.

Please Sign in or register to post replies

Write your reply to:

Draft