且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在C#中设置cookie值?

更新时间:2023-02-24 20:31:11

以下是我在MVC中管理cookie的方法

Here's how I have been managing the cookies in MVC
[HttpGet]
public ActionResult Details()
{
  HttpCookie cookie = new HttpCookie("MySiteCookie", "For the love of Pete, do not put unencrypted info in cookies!");
  Response.SetCookie(cookie);
  return View();
}

[HttpPost]
public ActionResult Details(int i)
{
  HttpCookie cookie = Request.Cookies["MySiteCookie"];
  // do something with the cookie
  return View(new Model.SomeData(i));
}


Cookie是在未连接Web服务器和浏览器期间存储有关网站访问者数据的几种方法之一。 />


查看有关C中设置cookie值的有用资源#



C#.NET:在.NET中获取和设置Cookie值 [ ^ ]



ASP.Net C中的Cookie# [ ^ ]



ASP.Net C#中的Cookie# [ ^ ]
Cookies are one of several ways to store data about web site visitors during the time when web server and browser are not connected.

check this useful resources about set cookie value in C#

C# .NET: Get and Set Cookie Values in .NET[^]

Cookies in ASP.Net C#[^]

Cookies in ASP.Net C#[^]