services.AddAuthentication("auth")
.AddCookie("auth",config=>
{
config.Cookie.Name = "cookie.name";
//config.LoginPath = "/home/login";
config.Events.OnRedirectToLogin = context =>
{
context.HttpContext.Items["Properties"] = context.Properties;
context.HttpContext.Features.Set(context.Properties);
var get=HttpContext.Session.Get("Properties");
return Task.CompletedTask;
};
});
如何在一个action请求里获取 Properties。HttpContext.Items["Properties"]的作用域仅限于一次请求,但我想在某个action中获取。
public IActionResult actionmethod()
{
var property = HttpContext.Items["Properties"];
var pro = HttpContext.Features.Get<AuthenticationProperties>();
var get=HttpContext.Session.Get("Properties");
return View();
}
能不能实现,或者有没有替代方法?