Copied to clipboard

Flag this post as spam?

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


  • pat 124 posts 346 karma points
    Feb 08, 2017 @ 11:36
    pat
    0

    partial view render from macro partial view not reach index method of controller

    Hi all,

    I am creating a partial view and need to redirect login page if member not logged in. I have call response.redirect("/login/?mymsg=1") from View

    Then in Login Controller Index Method I was trying to get request query string mymsg and set a TempData value to display on Login view.

    but I have noticed that my first view redirect to Login page but not setting up msg why Login Controller not execute Index Method ?

    public class icLoginController : SurfaceController { // GET: icLogin [HttpGet] public ActionResult Index() { TempData["displaymsg1"] = "TEST passmsg";
    string stmsg = setmsg(); if (!String.IsNullOrEmpty(stmsg)) { TempData["displaymsg"] = setmsg(); }

        return View();
    }
    public ActionResult Index(string  rd ,string mymsg)
    {
        TempData["displaymsg1"] = "TEST passmsg";
    
        string stmsg = set_msg();
        if (!String.IsNullOrEmpty(stmsg))
        {
            TempData["displaymsg"] = set_msg();
        }
    
        return View();
    }
    

    I have tried call renderPartial from first view and then pass viewdata so I can read it from Index

     { Html.RenderPartial("~/Views/Partials/myicCodeProject/icLogin.cshtml", new myicCodeProject.Models.icLoginModel(),new ViewDataDictionary { { "mymsg", "1" } }); }
    

    any help would be great

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Feb 14, 2017 @ 07:53
    Dave Woestenborghs
    0

    Hi Pat,

    @Html.RenderPartial does not use a controller.

    I'm gussing you are looking for @Html.Action("Index","icLogin")

    Dave

  • pat 124 posts 346 karma points
    Mar 13, 2017 @ 14:17
    pat
    0

    I can use Html.Action if you calling it in template ... but I need to call it using a macro so i don't need to create lot of templates to each form.

    but I can see that if i call it using partial that not hit index method in controller, in partial macro I cannot call Html.Action . In one testing i had infinite loop and execute submit method

    any idea how to sort this?

Please Sign in or register to post replies

Write your reply to:

Draft