احمد صدقی

احمد صدقی

  • NA
  • 106
  • 16.4k

Is there any Method to create Login form without Session.

Mar 29 2019 1:36 AM
I am creating my Login form in my project as same from Session, but now in this project i want to create Login form without using any session. Anyone here to guide me? There is my Work using Session,This is Controller of LogIn:
  1. public class LoginController : Controller  
  2. {  
  3. IMEI_WEB_MVC.Connections.IMEI_DBEntities imeidb = new Connections.IMEI_DBEntities();  
  4. Functions func = new Functions();  
  5. // GET: Login  
  6. public ActionResult Index()  
  7. {  
  8. return View();  
  9. }  
  10. [HttpGet] public ActionResult Autherize(log_variable logvariable_model)  
  11. {  
  12. log_variable lgv = new Models.log_variable();  
  13. string pwd = func.security(logvariable_model.usr_pwd);  
  14. var userDetails = imeidb.new_usr.Where(x => x.usr_nam == logvariable_model.usr_nam && x.usr_pwd == pwd).FirstOrDefault();  
  15. if (userDetails == null)  
  16. {  
  17. logvariable_model.LogErrorMessage = " Invalid Name or Password";  
  18. return View("Index", logvariable_model);  
  19. }  
  20. else  
  21. {  
  22. Session["usr_id"] = userDetails.usr_id;  
  23. Session["com_id"] = logvariable_model.com_id;  
  24. Session["br_id"] = logvariable_model.br_id;  
  25. //lgv.usr_id = userDetails.usr_id;  
  26. //lgv.com_id = logvariable_model.com_id;  
  27. //lgv.br_id = logvariable_model.br_id;  
  28. return RedirectToAction("index""m_dpt");  
This is my Model:
  1. public class log_variable  
  2. {  
  3. [Required(ErrorMessage = "User Name cannot be blank")]  
  4. [DisplayName("Name")]  
  5. public string usr_nam { getset; }  
  6. [Required(ErrorMessage = "Password cannot be Blank")]  
  7. [DataType(DataType.Password)] [DisplayName("Password")]  
  8. public string usr_pwd { getset; }  
  9. public int usr_id { getset; }  
  10. [Required(ErrorMessage = "Company ID cannot be blank")]  
  11. [MaxLength(2)] [DisplayName("Company_ID")]  
  12. public string com_id { getset; }  
  13. [Required(ErrorMessage ="Branch ID cannot be blank")]  
  14. [MaxLength(3)]  
  15. [DisplayName("BRANCH_ID")]  
  16. public string br_id { getset; }  
  17. public string LogErrorMessage { getset; } }  

Answers (1)