TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
611
128.1k
Remember me in .net core.
Nov 1 2020 11:14 PM
Hello Everyone
i have used this code for remember me in asp.net core. Remember me is not working. What's the issue with this code.
if
(ModelState.IsValid)
{
var userdetails = await _context.UserMaster
.SingleOrDefaultAsync(m => m.Email == model.Email && m.Password == model.Password);
if
(userdetails ==
null
)
{
ModelState.AddModelError(
""
,
"The user name or password is incorrect."
);
return
View(
"Login"
);
}
if
(userdetails !=
null
)
{
if
(userdetails.UserRoleId == 1)
{
var claims =
new
List<Claim>();
claims.Add(
new
Claim(ClaimTypes.Name, userdetails.Email));
var identity =
new
ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var principal =
new
ClaimsPrincipal(identity);
var props =
new
AuthenticationProperties();
props.IsPersistent = model.RememberMe;
HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, props).Wait();
HttpContext.Session.SetString(
"Name"
, userdetails.FullName);
HttpContext.Session.SetString(
"Image"
, userdetails.Image);
HttpContext.Session.SetString(
"Id"
, Convert.ToString(userdetails.UserId));
string
a = HttpContext.Session.GetString(
"Name"
);
string
b = HttpContext.Session.GetString(
"Image"
);
string
c = HttpContext.Session.GetString(
"Id"
);
please let me solution what's issue
Reply
Answers (
2
)
Getting radio button value & text without using asp.net controls
Not Getting value of “Quantity” and “Grand Total”