views:

96

answers:

2

I have a view named UserVerify with a returnUrl parameter, http://localhost:50383/register/UserVerify?returnUrl=http%3A%2F%2Flocalhost%3A50383%2Fregister%2Forganization.

The UserVerify view has a partial view control, LogonControl.

<% Html.RenderPartial("LogonControl"); %>

Here is the controller code for the LogonController

 public ActionResult LogonControl(string returnUrl)
        {
            return View();
        }

        [HttpPost]
        public ActionResult LogonControl(LogOnModel model,string returnUrl)
        {
            if (!String.IsNullOrEmpty(returnUrl))
            {
                return Redirect(returnUrl);
            }
            else
            {
                return RedirectToAction("Index", "Public");
            }      
        }

When I test, the returnUrl is not getting set, it is null. Any ideas on how to get the returnUrl down to the partial view?

Thanks

A: 

What you really need to look is action attribute of your form tag and take care that it contains returnUrl value.

Quick (and maybe not the best one) approach would be to pass returnUrl to routeValues as

@returnUrl=Request["returnUrl"]

Andrej Kaurin
A: 

The form was not passing back the value. Adding the value to BeginForm worked.

(Html.BeginForm("Logon", "Account", new { ReturnUrl = Request.QueryString["ReturnUrl"] }))
scottrakes