Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1d);
Response.Expires = -1500;
Response.CacheControl = "no-cache";
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
System.Web.Security.FormsAuthentication.SignOut();
if (Session["trainingpartnersession"] != null)
{
Session.Remove("trainingpartnersession");
}
if (Session["trainingpartnercookiessession"] != null)
{
Session.Remove("traincookiessession");
}
if (Request.Cookies["trainingartnerCookies"] != null)
{
Request.Cookies["trainingartnerCookies"].Expires = DateTime.Now.AddDays(-1);
new Cookies().RemoveCookies("trainingartnerCookies");
}
Session.Abandon();
Session.RemoveAll();
Response.Redirect("~/Login.aspx");
-----------------------------------------------------
and on page load and pre init function (logout facility)
protected void Page_Init(object sender, EventArgs e)
{
Browser.ClearBrowserData();
Page.ViewStateUserKey = Session.SessionID;
}
protected void Page_Load(object sender, EventArgs e)
{
string result = null;
try
{
if (!this.Page.IsPostBack)
{
if (Session["trainingpartnercode"] != null && Session["trainingpartnercode"].ToString().Length > 1)
{
//if (IsFinalStatus( Session["trainingpartnercode"]!=null? Convert.ToString(Session["trainingpartnercode"]):null))
//if(Session["FinalSubmit_Status"]!=null && Convert.ToString(Session["FinalSubmit_Status"]).Length > 0 && Convert.ToBoolean(Session["FinalSubmit_Status"].ToString())==true)
if (Session["finalStatus"] != null && Convert.ToString(Session["finalStatus"]).Length > 0 && Convert.ToBoolean(Session["finalStatus"]) == true)
{
PreviewProfile1.Visible = true;
lnkUpdateProfile.Visible = false;
CourseAppliedStatus.Visible = true;
ManageCourses.Visible = true;
ManageExam.Visible = true;
ManageFund.Visible = true;
ManageStudent.Visible = true;
ManageBatch.Visible = true;
Li1.Visible = true;
profileUpdate.Visible = true;
//new code 24092019
ManageInvoice.Visible = true;
if ((Isheme1or2(Session["State_code"] != null ? Convert.ToInt32(Session["State_code"].ToString()) : 0) == 1) || (Isheme1or2(Session["State_code"] != null ? Convert.ToInt32(Session["State_code"].ToString()) : 0) == 0))
{
Show(RegStudent);
Hide(A23);
}
else
{
Show(A23);
Hide(RegStudent);
}
}
else
{
// Hide(PreviewProfile1, lnkUpdateProfile);
PreviewProfile1.Visible = false;
lnkUpdateProfile.Visible = true;
CourseAppliedStatus.Visible = false;
ManageCourses.Visible = false;
ManageExam.Visible = false;
ManageFund.Visible = false;
ManageStudent.Visible = false;
ManageBatch.Visible = false;
Li1.Visible = false;
profileUpdate.Visible = false;
//new code 24092019
ManageInvoice.Visible = false;
}
}
else
{
Response.Redirect("~/Login.aspx?errormessage=No valid session found", false);
}
}
}
catch (Exception ex)
{
ExceptionHandler.WriteException(ex.Message);
} // comment by bibek
/* below code is for authentication */
if (Session["trainingpartnersession"] != null && Session["trainingpartnersession"].ToString().Length > 1)
{
if (Session["trainingpartnercookiessession"].ToString().Equals(new Cookies().GetCookies("trainingartnerCookies")))
{
string s = Session["trainingpartnercookiessession"]!=null? Session["trainingpartnercookiessession"].ToString():null;
string t = new Cookies().GetCookies("trainingartnerCookies");
// lbl_username.Text = Session["trainingpartnersession"].ToString();
result = Session["trainingpartnercode"].ToString() + " | " + Convert.ToString(Session["TP_Name"]) + " | " + Convert.ToString(Session["TP_State"]);
lbl_username.Text = result.ToUpper();
}
else
{
//Session.RemoveAll();
//
//Response.Redirect("~/Login.aspx", false);
FormsAuthentication.SignOut();
Request.Cookies.Remove("trainingartnerCookies");
new Cookies().RemoveCookies("trainingartnerCookies");
Session.RemoveAll();
Browser.ClearBrowserData();
Response.Redirect("~/Login.aspx");
}
}
else
{
Session.RemoveAll();
Browser.ClearBrowserData();
Response.Redirect("~/Login.aspx", false);
}
}
No comments:
Post a Comment