8

I'm converting a .net 4.7 MVC project to .net core 2, attempting to preserve as much of the code, as is, as possible. This project has a BaseService that builds an AuthCookie that's consumed by a few other services throughout the application.

// Create
public HttpCookie AuthCookie { get; set; } = new HttpCookie(AuthUtils.CookieName);

// Consume
if (AuthCookie?.Value != null) { ... }

In .net 4.7, the HttpCookie class is included in the System.Web namespace, but doesn't seem to exist in .net core 2 in the same way. As in, a cookie is built and handled outside the context of a controller.

I've seen: Why I can't use HttpContext or HttpCookie? (Asp.Net Core 1.0)

That doesn't seem to address this question. Is the fundamental difference in authentication handling in .net core so big that this case can't be handled?

Will Luce
  • 1,781
  • 3
  • 20
  • 33
  • go through this: https://www.c-sharpcorner.com/article/asp-net-core-working-with-cookie/ – Adithya Sai Jul 16 '18 at 09:26
  • Try using CookieBuilder https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.cookiebuilder?view=aspnetcore-5.0#:~:text=Properties%20%20%20Domain%20%20%20The%20domain,for%20the%20cookie.%20%204%20more%20rows%20 – cskwg Nov 26 '21 at 15:48

0 Answers0