-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_LayoutMain.master.cs
More file actions
82 lines (72 loc) · 2.16 KB
/
_LayoutMain.master.cs
File metadata and controls
82 lines (72 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _LayoutMain : System.Web.UI.MasterPage
{
string conString = ConfigurationManager.ConnectionStrings["MessengerConnection"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
}
public Image imgprofile
{
get { return this.ImageProfile; }
}
public Label lblusername
{
get { return this.lbluser; }
}
public LinkButton logout
{
get { return this.linklogout; }
}
public LinkButton signup
{
get { return this.linksignup; }
}
public LinkButton login
{
get { return this.linklogin; }
}
protected void linklogout_Click(object sender, EventArgs e)
{
try
{
if (lbluser.Text != null || Session.Timeout != 0)
{
SqlConnection con = new SqlConnection(conString);
SqlCommand cmd = new SqlCommand("UPDATE UsersData SET Status = 0 WHERE Username='" + Session["UserName"].ToString() + "'", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
FormsAuthentication.SignOut();
Session.Abandon();
HttpContext.Current.Session.Abandon();
Session.RemoveAll();
Response.Redirect("login.aspx");
}
else
{
FormsAuthentication.SignOut();
}
}
catch (Exception ex)
{
Session.Timeout = 0;
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Javascript", "alert('error : " + ex + "'); ", true);
Session["Name"] = null; //kill session
Session.Abandon();
// Session.Clear();
FormsAuthentication.SignOut();
Session.RemoveAll();
HttpContext.Current.Session.Abandon();
Response.Redirect("Login.aspx");
}
}
}