0
我的第一ActionController的是:如何传递控制器之间参数(隐藏在URL)-mvc
return RedirectToAction("Index", "Authentication",new {code = result });
和我使用在不同势控制器中的“结果”参数。像
public ActionResult Index(string code)
{
...
TempData["valcode"] = code;
return View();
}
[HttpPost]
public ActionResult AuthenticateUser(string validationcode)
{
if (validationcode == TempData["valcode"].ToString())
{
return RedirectToAction("Index", "Home");
}
else
{
...
}
}
它工作正常,但在url中,我看到的代码值。 (http://www.test.com/Authentication/code=123) 我不想要代码值在url中看到
我怎么能隐藏它的网址? (除了加密)
你不能。你的控制器方法不是通灵。如果您没有通过该值,那么控制器无法接收它。您始终可以使用'TempData',但只能持续一个请求,并且在用户刷新浏览器时会丢失。 –