简体   繁体   English

C#Core MVC用户身份/如何保存上次登录(通过Cookie)

[英]c# Core MVC user identity / how can I save last login (via cookie)

I use the user identity in c# Core MVC - this works perfect but I want to save the lastlogin and a log if a user login via cookie ("remember me" function). 我在c#Core MVC中使用用户身份-可以完美运行,但是如果用户通过cookie登录(“记住我”功能),我想保存lastlogin和日志。

Where can I add my functionality? 在哪里可以添加我的功能?

Thanks a lot Ralf 非常感谢Ralf

if someone has the same problem. 如果有人有同样的问题。

I added in the user-model: public Nullable UserDataLastLogin { get; 我在用户模型中添加了:public Nullable UserDataLastLogin {get; set; 组; } }

and add in the login-function if login is sucessfull 如果登录成功,并添加登录功能

user.UserDataLastLogin = DateTime.Now; user.UserDataLastLogin = DateTime.Now; _context.SaveChanges(); _context.SaveChanges(); HttpContext.Session.SetString("Loginsucess", DateTime.Now.ToString()); HttpContext.Session.SetString(“ Loginsucess”,DateTime.Now.ToString());

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

相关问题 ASP.NET 核心。 如何在没有身份用户帐户的情况下创建身份验证 cookie? - ASP.NET Core. How can i create an auth cookie without an identity user account? 如果用户使用 ASP .Net Identity 通过外部登录提供程序登录,如何保存用户上次登录日期? - How to save user last login date if he was logged in with external login provider using ASP .Net Identity? 如何从 C# MVC .net 核心中的用户名(身份名称)获取 Azure AD 用户组名称? - How to get the Azure AD User Group Name from User Name (Identity Name) in C# MVC .net core? 登录后使用C#身份与用户合作 - Work with the user after login, C# Identity 我如何通过 c# 登录 Instagram - How can ı login instagram via c# 如何在C#中登录Novell Groupwise用户帐户? - How can I login to a Novell Groupwise user account in C#? 如何使用.Net Core cookie中间件ticketdataformat将Jwt令牌从Api保存到C#中的cookie - How to save Jwt token from Api to cookie in c# using .Net Core cookie middleware ticketdataformat C#MVC身份-验证“信息亭用户” - C# MVC Identity - Authenticating a “Kiosk User” 如何在 ASP.NET Core MVC 中向身份用户添加名字/姓氏属性? - How to add first/last name properties to Identity user in ASP.NET Core MVC? C#如何通过HttpWebRequest调用具有相同cookie的多个POST,GET请求? - C# How can I call multiple POST, GET requests with same cookie via HttpWebRequest?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM