![](/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.