hholtij
hholtij

Reputation: 2936

Cookies in ASP.NET Core rc2

Can someone pls explain how to store and get cookies in an ASP.NET Core rc2 application? I can only find outdated information about the old HttpContext.Response.Cookies.Get and Add methods, neither of which still exist in Core. Also, the HttpCookie class doesn't seem to exist either.

What is the new cookie class and how can I get and add one?

(Note: I am not specifically taking about authentication cookies, just general data cookies)

Upvotes: 5

Views: 3120

Answers (1)

adem caglin
adem caglin

Reputation: 24083

For getting request cookie value:

HttpContext.Request.Cookies["<key>"]

Setting response cookie:

HttpContext.Response.Cookies.Append("<key>", <value>, <options?>)

Upvotes: 13

Related Questions