我想在ASP.net MVC中添加一些东西给cookie.
什么是处理cookie或更多cookie中所有内容的最佳方法.
在asp.net mvc中处理cookie的任何好方法?
Dar*_*rov 17
这是一个例子:
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();
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11375 次 |
最近记录: |