cookie管理在ASP.NET MVC [英] Cookie management in ASP.NET MVC
本文介绍了cookie管理在ASP.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想补充一些东西在ASP.net MVC到cookie中。
I want to add some stuff to cookie in ASP.net MVC.
什么是处理所有的东西在Cookie或更多的cookie最佳方式。
What is best way to handle all stuff in a cookie or more cookie.
要处理的cookie在asp.net mvc的什么好办法?
Any good way to handle cookie in asp.net mvc?
推荐答案
下面是一个例子:
public class HomeController : Controller
{
public ActionResult CreateCookie()
{
var cookie = new HttpCookie("cookie_name", "some value");
Response.AppendCookie(cookie);
return View();
}
public ActionResult ReadCookie()
{
var cookie = Request.Cookies["cookie_name"];
if (cookie != null)
{
string value = cookie.Value;
}
return View();
}
}
这篇关于cookie管理在ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文