问个ASP.NET MVC的Cookie问题。

AccountController 代码:
public ActionResult Index() {
Response.Cookies["aa"].Value = "aa";
return RedirectToAction("Index", "Home");
}

HomeController代码:
public void Index() {
Response.Write(Response.Cookies["aa"].Value);
}

为啥显示不出来?

一只斗牛犬
浏览 510回答 2
2回答

慕勒3428872

把.value 去掉试试设置COOKIESResponse.Cookies("CookieName")=title获取COOKIEStitle=Request.Cookies("CookieName")清除COOKIESresponse.cookies("CookieName")=""

翻翻过去那场雪

显示已有cookie值得时候应该用Request.Cookies["aa"].Value
打开App,查看更多内容
随时随地看视频慕课网APP