Below are a few different ways I'm trying to set cookies for a user. I don't understand why I'm getting an error on the HttpCookie. If someone knows what I'm doing wrong please let me know or if you need more details on my problem.
Asked
Active
Viewed 5,720 times
4
-
Hi @AverageGuyIssac, does your project using `asp.net-mvc` or `asp.net-core-mvc`? Both frameworks are different. – Yong Shun Apr 29 '21 at 01:49
-
@YongShun I am using asp.net-core-mvc – AverageGuyIsaac Apr 29 '21 at 15:03
-
Hi @AveargeGuyIssac, your question is same as [HttpCookie class in aspnet core 2](https://stackoverflow.com/q/48495314/8017690). You can read this post & also its linked duplicate questions as well. Thanks. – Yong Shun Apr 30 '21 at 01:43
-
Might you please [edit] your question to include your code and other textual content as **text** rather than as a screen shot? It's preferred not to use images for this purpose here, see [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/a/285557) and [Discourage screenshots of code and/or errors](https://meta.stackoverflow.com/q/303812) for why. – dbc Apr 30 '21 at 05:42
1 Answers
3
Download Package Microsoft.AspNetCore.Http using Nuget Package Manager, refer this package in your class by writing using Microsoft.AspNetCore.Http;
Instead of HTTPCookie class ,You need to use CookieOptions Class as follow
CookieOptions langCookie=new CookieOptions(); langCookie.Expires=DateTime.Now.AddYears(1);

durgaprasad
- 31
- 1
- 4