如何将 EmployeeId 和 DesignationId 添加到一个对象中,并在之后从 Session 状态中检索它?
这是我的登录控制器代码:
DataTable dt = sql.GetDataTable("select * from EmpDetails where EmailId = '" + EmailId + "'");
string strempstatus = dt.Rows[0]["Status"].ToString();
string EmpStatus = strempstatus.TrimEnd();
//Models.UserDetails detail = new Models.UserDetails();
if (EmpStatus == "Verified")
{
//i want to create object which store below two variable value
string EmployeeId = dt.Rows[0]["Id"].ToString();
string DesignationId = dt.Rows[0]["D_Id"].ToString();
//I want to stored object in below session
HttpContext.Session.SetString("EmployeeData", EmployeeId);
HttpContext.Session.SetInt32("EmployeeID", Convert.ToInt32(EmployeeId));
//For Destroy Session
//HttpContext.Session.Remove("EmployeeID");
Int32? Saved = HttpContext.Session.GetInt32("EmployeeID");
if (DesignationId == "1")
{
return RedirectToAction("Index", "AdminDashboard");
}
else
{
return RedirectToAction("Index", "UserDashboard");
}
}
ConfigureServices()
方法的代码。您是否收到任何错误? - Krishnraj Rana