Mark Tabor

Mark Tabor

  • 924
  • 1.5k
  • 254.5k

My lines are not executing where i am setting session in asp.net mvc

May 1 2021 7:52 AM
Hi the Lines where i am setting session are not executing while i debug the application
if (!string.IsNullOrEmpty(loginViewModel.Email_Address) && !string.IsNullOrEmpty(loginViewModel.Password))
{
var Username = loginViewModel.Email_Address;
var password = EncryptionLibrary.EncryptText(loginViewModel.Password);
var result = _IStudent.ValidateUser(Username, password);
string sName = result.Student_FName;
Session["UserName"] = sName;
var urls = _IStudent.GetImageURL(Username);
Session["PthUrl"] = urls;
if (result != null)
{
if (result.Student_Id == 0 || result.Student_Id < 0)
{
ViewBag.errormessage = "Entered Invalid Username and Password";
}
else
{
//var RoleID = result.RoleID;
remove_Anonymous_Cookies(); //Remove Anonymous_Cookies
}
// Session["RoleID"] = Convert.ToString(result.RoleID);
Session["Username"] = Convert.ToString(result.Student_FName);
Session["UserID"] = Convert.ToString(result.Student_Id);
Session["StudentEmailAddress"] = Convert.ToString(result.Student_Email);
Session["UserType"] = Convert.ToInt32(result.User_type);
if (!string.IsNullOrEmpty(url))
{
return Redirect(url);
}
else
{
return RedirectToAction("Dashboard", "StudentLogin");
}
}
else
{
ViewBag.errormessage = "Email Address and password are not valid Or the administrator did not activate your account ! contact the system administrator";
return
 

Answers (2)