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
Dr.Ajay Kashyap
NA
521
285.1k
How to Implement remember me in Asp.net Mvc
Feb 16 2017 1:58 AM
I want to implement remember Me In my Login Page And I Dont Have Any Idea How To Implement it ... Soo Please Any One Help Me Solve This Problem..
[HttpGet]
public ActionResult Login()
{
return View();
}
[HttpPost]
public ActionResult Login(ViewModels.LoginViewModel LogUser)
{
var validUser2 = this.db.SystemUserDetails.FirstOrDefault(a => a.EmailId == LogUser.EmailId || a.ContactNo == LogUser.EmailId);
if (validUser2 != null)
{
var ValidUser = this.db.LoginDetails.FirstOrDefault(u => u.LoginID == validUser2.LoginId);
if (ValidUser != null)
{
if (DecryptPass == LogUser.Password)
{
VendorUserHistoryAndActivity vuha = new VendorUserHistoryAndActivity();
vuha.LoginId = Convert.ToInt32(Session["userid"]);
vuha.Created_By = Convert.ToInt32(Session["userid"]);
vuha.Created_Of_Designation = Session["designation"].ToString();
vuha.Created_By_Designation = Session["designation"].ToString();
vuha.All_Id = Convert.ToInt32(Session["userid"]);
vuha.Activity = "login";
vuha.Activity_On = "login";
vuha.Created_On = DateTime.Now;
db.VendorUserHistoryAndActivities.Add(vuha);
db.SaveChanges();
TempData["msg"] = null;
return RedirectToAction("Index1", "Home", new { msg = "Welcome To ShopINdeal!" });
}
else
{
ModelState.AddModelError("", "Password Is Incorrect");
return View(LogUser);
}
}
else
{
ModelState.AddModelError("", "Wrong Login Details.");
return View(LogUser);
}
}
else
{
ModelState.AddModelError("", "Wrong Login Details.");
return View(LogUser);
}
}
ViewModel:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ShopINdeal.Models;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity.Spatial;
using System.Web.Mvc;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace ShopINdeal.ViewModels
{
public class LoginViewModel
{
public int LoginID { get; set; }
[Required(ErrorMessage = "Password Must Be", AllowEmptyStrings = false)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
public string EmailId { get; set; }
public int ContactNo { get; set; }
}
}
Reply
Answers (
7
)
EntityState.Modified not working properly
accessing table data