You should pass the ReturnUrl data in your form when it's submitted like.
@Html.BeginForm("Login", "Account", new { ReturnUrl = "data" }, FormMethod.Post, new {}){}
Question
MVC 4
Razor
C#
Forms.Authentication
I marked a controller with the [Authorize]
attribute. It correctly takes me to the Login page.
In my address bar I see the ReturnUrl as ?ReturnUrl=%2f
Here is my [HttpPost] method.
[HttpPost]
public ActionResult Login(string ReturnUrl)
{
return Redirect(ReturnUrl);
}
However the ReturnUrl
in this method is null. My form is correctly pointed to Account/Login as a post.
What am I missing here, shouldn't the ReturnUrl be populated with the %2f?
Solution
You should pass the ReturnUrl data in your form when it's submitted like.
@Html.BeginForm("Login", "Account", new { ReturnUrl = "data" }, FormMethod.Post, new {}){}