Friday, 4 May 2018

Single user login at a time using asp.net c#

//////////////// at login page load event


public System.Data.DataTable dtSessionGlobal = new DataTable();
    string clientIp = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        Session["OptionDB"] = null;
        if (Cache["UserSessions"] != null)
        {
            dtSessionGlobal = (DataTable)Cache["UserSessions"];
            if (dtSessionGlobal.Columns.Count == 0)
            {
                dtSessionGlobal.Columns.Add("UserName");
                dtSessionGlobal.Columns.Add("SessionID");
            }
        }
        else
        {
            dtSessionGlobal.Columns.Add("UserName");
            dtSessionGlobal.Columns.Add("SessionID");
            Cache["UserSessions"] = dtSessionGlobal;
        }
    }

////////////////////////


if (dtSessionGlobal.Rows.Count > 0)

        {
            System.Data.DataRow[] dr = dtSessionGlobal.Select(" UserName='" + Session["UName"] + "'");
            if (dr.Length > 0)
            {
                /// write code here which you want
                return;

            }
        }

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...