Reputation: 28560
I have a return url send after a user logs in:
e.g.
/Account/SignIn?ReturnUrl=%2fToDoItems%2fCreate
However, the value in the controller isn't binding.
[HttpPost]
[ActionName("SignIn")]
public ActionResult SignInConfirmation(UserCredentialsModel model, string returnUrl)
{
if (ModelState.IsValid)
Also, the Request.QueryString
is empty (bar the Length
).
How do I bind the query string params to the controller?
As per below, I've tried capitalising the parameter name:
public ActionResult SignInConfirmation(UserCredentialsModel model, [Bind(Include = "ReturnUrl")] string ReturnUrl)
Upvotes: 0
Views: 564
Reputation: 62300
You want to retrieve ReturnUrl from HttpGet method, and send it back on postback.
@using (Html.BeginForm("SignInConfirmation", "YOUR_CONTROLLER",
new { ReturnUrl = ViewBag.ReturnUrl },
FormMethod.Post, new { role = "form" }))
{
....
}
public ActionResult SignInConfirmation(string returnUrl)
{
ViewBag.ReturnUrl = returnUrl;
return View();
}
[HttpPost]
public ActionResult SignInConfirmation(UserCredentialsModel model, string returnUrl)
{
}
Upvotes: 2