Copied to clipboard

Flag this post as spam?

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

  • P.J. Melies 9 posts 89 karma points
    23 days ago
    P.J. Melies

    Render controller for Macro

    We have a macro partial view that requires us to run some logic in a controller in the GET action based on query string parameters before rendering the partial view.

    We have a corresponding surface controller to handle POST actions but I can't figure out how to hook into the GET action in order to run the required logic on the initial request.

    I've tried coding Index() and Render() methods in the surface controller but those are never executed.

    Is it even possible for me to do what I'm attempting? If not I could just create a specific document type, template and partial view but we were hoping to keep this logic in a macro to make it easier on the designer.

  • Huw Reddick 410 posts 1097 karma points
    5 days ago
    Huw Reddick

    I don't think you can achieve what you want, however there may be a way around it, what exactly do you need to do?

    If you want to pass values to the macro based on the querystring, you could maybe do something like

    In your MacroPartial

    @Html.Action("Index", "MacroTestSurface", new { request = Request.QueryString })
    @if (TempData.ContainsKey("page"))
        <p>Page = @TempData["page"]</p>


    public class MacroTestSurfaceController : SurfaceController
        public ActionResult Index()
            if (Request.QueryString.AllKeys.Contains("page"))
                TempData["page"] = Request.QueryString["page"];
            return Content("");
Please Sign in or register to post replies

Write your reply to: