Cookie Management in ASP.NET MVC

I want to add some things to the cookie in ASP.net MVC.

What is best to handle all things in a cookie or more cookies.

Any good way to handle cookies in asp.net mvc?

+4
source share
2 answers

Here is an example:

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(); } } 
+16
source

Source: https://habr.com/ru/post/1314302/


All Articles