![](/img/trans.png)
[英]How can I use both Bearer and Cookie authentication in my ASP.net Core application?
[英]How can I change this problem for ASP.NET Core 7.0?
这个项目是在.NET 4.6上为ASP.NET创建的,但现在我会尝试将它移动到ASP.NET Core 7.0。
在 ASP.NET Core 7 中,我可以写什么来代替这段代码?
旧的LoginController
:
var cookie = System.Web.HttpContext.Current.Request.Cookies.Get(".Test");
if (checkCookieName != null)
{
Response.Cookies[".Test"].Expires = DateTime.Now.AddDays(-1);
}
HttpContext.Response.Cookies.Append()
它创建了一个新的 cookie,所以对我没有帮助
你可以尝试如下:
string val;
var exist=HttpContext.Request.Cookies.TryGetValue(".Test",out val);
if(exist==true)....
HttpContext.Response.Cookies.Append(".Test","targetvalue",new CookieOptions(){Expires=.....})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.