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',但只能持續一個請求,並且在用戶刷新瀏覽器時會丟失。 –