我正在开发一个应用程序,使用VS 2010和MVC4(Razor)。我被卡住的Url参数。我能够实现LogIn方法。有一次,我验证用户我想他重定向到其他页面,所以我用隐藏URL中的参数MVC4
RedirectToAction("UserAction","User",new{userID = "",password=""});
但问题是RedirectToAction usses HTTTPGet所有的URL参数,用户ID和密码是可见的。
如何使用HTTPPost调用RedirectToAction。
任何帮助将不胜感激。 这里是我的Login.cshtml
@using (Html.BeginForm("SignIn", "Login", FormMethod.Post))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Log in Form</legend>
<ol>
<li>
@Html.LabelFor(m => m.UserName)
@Html.TextBoxFor(m => m.UserName, new { id = "UserName" })
@Html.ValidationMessageFor(m => m.UserName)
</li>
<li>
@Html.LabelFor(m => m.Password)
@Html.PasswordFor(m => m.Password, new { id = "Password" })
@Html.ValidationMessageFor(m => m.Password)
</li>
</ol>
<input type="submit" value="Log in"/>
</fieldset>
}
这里是我的登录控制器
bool IsValidUser = ValidateEachUser(oLoginModel.
UserName,oLoginModel.Password);
if (IsValidUser)
return (RedirectToAction("UserDetails", "User", new { userID = userID,
password =
password }));
else
return View("Login");
感谢名单和问候
为什么你会在登录后在UserDetails视图中需要密码?不够UserId? –
我需要密码,因为对于用户进行的每个操作,我都应该验证用户。 – user1418667
我已经用Google搜索,很多链接都说使用HTTPPOST。但我不知道如何实现这一点,因为登录控制器中的SignIn方法是HTTPPOST方法。我如何使RedirectToAction成为POST。 – user1418667