I am "upgrading" from old .net to .net core 2.2 (obviously it's not such as easy upgrade as it is a re-write)
This
HttpCookieCollectionis not so accessible anymore. For .Net Core 2.2 class library what are some examples of how to get access to this cookie collection?
private static string CollectionToHtmlTable(HttpCookieCollection collection)
{
// Converts HttpCookieCollection to NameValueCollection
var nvc = new NameValueCollection();
foreach (string item in collection)
{
var httpCookie = collection[item];
if (httpCookie != null)
{
nvc.Add(item, httpCookie.Value);
}
}
return CollectionToHtmlTable(nvc);
}
I believe the equivalent class would be IRequestCookieCollection
An instance of this object can be accessed in the request instance via HttpContext.Request.Cookies in a controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With