Copied to clipboard

Flag this post as spam?

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


  • David Armitage 508 posts 2077 karma points
    Dec 17, 2014 @ 00:58
    David Armitage
    0

    Umbraco Partial Macro Error - Action called / runs twice

    Hi,

    I've coded a partial macro which references a partial view form.

    eg.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage   
    @Html.Action("ChangeMemberPassword","MemberSurface")

     

    For some reason the Htem.Action gets called twice. This creates errors as by partial view controller checks the query string. The first time it runs the query string is present but the second time it is empty.

    I add the Partial Macro to the page through the content editor. Both 'use in rich text editor' & 'render in rich text editor' are ticked

    eg.

    <div class="umb-macro-holder mceNonEditable"><!-- <?UMBRACO_MACRO macroAlias="changeMemberPassword" /> --> <ins>Macro alias: <strong>changeMemberPassword</strong></ins></div>

     

    Can anyone help me on this. It's pretty annoying as its happening on a few Partial Macros which are setup like this.

     

    Thanks

    David

     

     

     

  • David Armitage 508 posts 2077 karma points
    Dec 17, 2014 @ 01:05
    David Armitage
    0

    If It makes any difference here is my ServiceController

    [HttpGet]
            [ActionName("ChangeMemberPassword")]
            public ActionResult ChangeMemberPasswordGet()
            {
                var memberId = Request.QueryString["id"] != null ? int.Parse(Request.QueryString["id"].ToString()) : 0;
               
                if(memberId > 0)
                {
                    var model = new ChangeMemberPasswordModel();
                    var member = UserManager.GetMemberById(memberId);
                    if(member != null)
                    {
                        if (UserManager.IsMemberInAdminRole(model.CurrentMember.Username) || member.Username == model.CurrentMember.Username)
                        {
                            model.Member = member;
                            return PartialView("ChangeMemberPassword", model);
                        }
                        else
                        {
                            return Redirect("~/access-denied");
                        }
                    }
                    else
                    {
                        return Redirect("~/page-not-found");
                    }
                }
                else
                {
                    return Redirect("~/page-not-found");
                }
            }

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Dec 17, 2014 @ 08:35
    Dave Woestenborghs
    0

    Do you have the same issue if you call your action directly from your template ?

    Dave

  • Ste 14 posts 35 karma points
    Dec 17, 2014 @ 10:43
    Ste
    0

    Hi David,

    Looking in my projects, wherever I have this pattern, the page calling @Html.Action is of type UmbracoViewPage, not PartialViewMacroPage.

    I think this is the same thing Dave is saying - if you don't use the Rich Text Editor but just put the @Html.Action call directly into your template, maybe it will work differently? Other than that, I know that my Controller GET actions are doubled if I ever navigate to them directly within Firefox, but I don't think that's related here.

  • Ste 14 posts 35 karma points
    Dec 17, 2014 @ 10:43
    Ste
    0

    Hi David,

    Looking in my projects, wherever I have this pattern, the page calling @Html.Action is of type UmbracoViewPage, not PartialViewMacroPage.

    I think this is the same thing Dave is saying - if you don't use the Rich Text Editor but just put the @Html.Action call directly into your template, maybe it will work differently? Other than that, I know that my Controller GET actions are doubled if I ever navigate to them directly within Firefox, but I don't think that's related here.

  • David Armitage 508 posts 2077 karma points
    Dec 17, 2014 @ 15:14
    David Armitage
    0

    Hi,

    Looking forther into the issue...

    I noticed that this issue is happenig on other if not all macro calls with the standard setup. For example..

     

    I have one standard umbraco razor template page calling a standard umbraco macro and the macro gets called twice everytime. Eg...

    Simplified Code...

    Umbraco Page:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using CMS.Utils

    @{
        Layout = "SiteDesign.cshtml";
    }
    <div id="main-content">
            @Umbraco.RenderMacro("galleryAlbumsLatest", new { displayCount = 3 })
    </div>

    Macro Partial View:

    @using CMS.pocos;
    @using CMS.Utils;
    @inherits Umbraco.Web.Macros.PartialViewMacroPage

    @{

        *****THIS GETS HIT TWICE******
        var displayCount = !string.IsNullOrEmpty(Model.MacroParameters["displayCount"].ToString()) ? int.Parse(Model.MacroParameters["displayCount"].ToString()) : 3;
        List<GalleryAlbum> albums = PhotoGalleryManager.GetGalleryAlbumsLatest(displayCount);
    }

    <div>

            *****JUST STANDARD HTML HERE (NOTHING IMPORTNT) ******

    </div>

     

     

Please Sign in or register to post replies

Write your reply to:

Draft