문제

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?

도움이 되었습니까?

해결책

You should pass the ReturnUrl data in your form when it's submitted like.

@Html.BeginForm("Login", "Account", new { ReturnUrl = "data" }, FormMethod.Post, new {}){}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top