简体   繁体   English

.net core 3.1 中 RequestCookieCollection 和 ResponseCookies 的替代方案是什么?

[英]what's the alternative of RequestCookieCollection and ResponseCookies in .net core 3.1?

after migration from 2.2 to 3.1, ResponseCookies and RequestCookieCollection protection level was changed.从 2.2 迁移到 3.1 后,ResponseCookies 和 RequestCookieCollection 保护级别发生了变化。 what is the alternative in 3.1 ? 3.1 中的替代方案是什么? enter image description here在此处输入图片说明

According to this github post, https://github.com/dotnet/aspnetcore/issues/18193 , RequestCookieCollection() was deliberately made internal so you have to use the interface IRequestCookieCollection.根据这个 github 帖子https://github.com/dotnet/aspnetcore/issues/18193 ,RequestCookieCollection() 是故意在内部进行的,因此您必须使用接口 IRequestCookieCollection。

If you notice, Visual studio auto suggests using the interface in both situations.如果您注意到,Visual Studio auto 建议在两种情况下都使用该界面。

Visual Studio 自动建议使用 IResponseCookies 代替 ResponseCookies

Visual Studio 自动建议使用 IRequestCookieCollection 代替 RequestCookieCollection

You can either use the interface or copy the implementation code and use it directly but that leaves you with possibility of a change being introduced that makes the copied code out of date.您可以使用接口或复制实现代码并直接使用它,但这可能会引入更改,从而使复制的代码过时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 .NET Core 3.1 中,RequestCookieCollection 不能再用于在单元测试中创建 cookies - In .NET Core 3.1, the RequestCookieCollection can no longer be used to create cookies in unit tests 在迁移到 .Net Core 3.1 时,.Net Core 2.2 中使用的 Services.AddMvc() 和 SuperJsonOutputFormatter 的替代方法是什么 - what is the alternative for Services.AddMvc() and SuperJsonOutputFormatter used in .Net Core 2.2 while migrating to .Net Core 3.1 mstest 的 DataSource 属性的 .Net 核心替代品是什么? - What`s .Net core alternative of DataSource attribute for mstest? 关于 .NET Core 3.1 和 Angular SSR spa.UseSpaPrerendering 替代方案的问题 - Questions on .NET Core 3.1 & Angular SSR spa.UseSpaPrerendering alternative .NET Core 3.1 中实体的等价物是什么? - What can be the equivalent of entity in .NET Core 3.1? 在 .NET Core 3.1 API 中验证 http 请求的好方法是什么? - What is good approach to validate http request in .NET Core 3.1 API's? 如果我的 aspnet mvc 应用程序以“.NET Core 3.1”为目标,它会针对哪个版本运行? - What point release(s) does my aspnet mvc app run against if it targets “.NET Core 3.1”? .NET 核心 3.1 的 GraphQL - GraphQL for .NET core 3.1 .Net Core 3.1 上的 AutoMapper - AutoMapper on .Net Core 3.1 .net core 3.1中的ExpressionMetadataProvider - ExpressionMetadataProvider in .net core 3.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM