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
129.5k
Error in a code.
Mar 26 2020 6:39 AM
public ActionResult Login(string EmailId, string Password, AdminMaster U)
{
FanzdbEntities _db = new FanzdbEntities();
AdminMaster Obj_AdminMaster = new AdminMaster();
HttpCookie cookie = new HttpCookie("user");
try
{
if (ModelState.IsValid == true)
{
if (U.RememberMe == true)
{
cookie["FirstName"] = U.EmailId;
cookie["Password"] = U.Password;
cookie.Expires = DateTime.Now.AddMinutes(5);
HttpContext.Response.Cookies.Add(cookie);
}
else
{
cookie.Expires = DateTime.Now.AddDays(-1);
HttpContext.Response.Cookies.Add(cookie);
}
}
AdminMaster obj_AdminMaster = _db.AdminMasters.Where(ad => ad.EmailId == EmailId && ad.Password == Password).FirstOrDefault();
if (obj_AdminMaster != null)
{
// return View("AllUsers","UserManagement");
Session["FirstName"] = obj_AdminMaster.FirstName;
Session["AdminId"] = obj_AdminMaster.AdminId;
return Json(new { status = true });
//return RedirectToAction("AllUsers","UserManagement");
}
else
{
return Json(new { status = false });
}
}
catch (Exception ex)
{
return Json(new { status = false });
}
}
It's me login code and remeberme code.
<script type="text/javascript">
//$(document).ready(function () {
$('#btnAdminLogin').click(function () {
var EmailId = $("#txtEmailId"),
RememberMe = $("#exampleCheck1"),
Password = $("#txtPassword");
if ($('#txtEmailId').val() == "" || $('#txtPassword').val() == "" || $('#lblRemeber').val()) {
alert("Please fill all required fields");
return false;
}
else {
$.ajax({
url: 'Login/Login',
type: 'Post',
dataType: 'json',
data: { "EmailId": $('#txtEmailId').val(), "Password": $('#txtPassword').val(), /*"RememberMe": $('#exampleCheck1').val()*/ },
success: function (data) {
var status = data.status;
if (status == true) {
var url = "/UserManagement/AllUsers";
window.location.href = url;
}
else {
alert("wrong credentials");
return false;
}
},
failure: function (data) {
alert("Something went wrong");
}
});
}
});
</script>
It's jquery code. I want check a checkbox and click login button not a store value in cookies. Please solve my error.
Jquery code.
Reply
Answers (
1
)
remember me in mvc with jquery.
Shift physical images from Database to local Disk