Login is changed by other users if 2 or more users click on same page at same time
<p>In my application when two or more users logged in and if they click on same page at same time(at exact time) then one's login is changed by others login .
The code on my page load event is as followes.</p>

<pre><code>MembershipUser mUser = Membership.GetUser();

if (mUser != null)
{
    aspUserId.Value = mUser.ProviderUserKey.ToString();
    DBHandler dbHandler = new DBHandler();
    SqlCommand cmd = new SqlCommand();
    cmd.Parameters.AddWithValue("@AspNetUserID", mUser.ProviderUserKey);
    string sPMSUserId = dbHandler.GetSingleValue(cmd, "get_PMSUserId");
    hdnUserID.Value = sPMSUserId;


}
else
{
    Response.Redirect("~/index.aspx");
}
</code></pre>

<p>hdnUserID is used to pass value to sqlDatasource select statement parameter.
 aspUserId is also i used to test aspnet_UserID of user. I test it by using inspect element
 .I found that it's value is changed by other user's aspnet_UserID.</p>

<p>in DBHandler i used connection string as like  </p>

<pre><code>string strconn = ConfigurationManager.ConnectionStrings["strconn"].ConnectionString; 
</code></pre>

<p>with code like that </p>

<pre><code> public string GetSingleValue(SqlCommand sqlcmdWithParameters, string CommandText) 
{ 
    string sReturn = ""; 
    SqlConnection sqlcon = new SqlConnection(strconn); 
    sqlcmdWithParameters.Connection = sqlcon; 
    sqlcmdWithParameters.CommandType = CommandType.StoredProcedure; 
    sqlcmdWithParameters.CommandText = CommandText; 
    try 
    { 
        sqlcon.Open(); 
        sReturn = Convert.ToString(sqlcmdWithParameters.ExecuteScalar()); 
    } 
    catch (Exception ex) 
    { 
        sReturn = "-1"; 
    } 
    finally 
    { 
        sqlcon.Close(); 
    } 
    return sReturn; 
} 
</code></pre>

<p>Finally I  got cause of problem. Yeah it is due to Cache </p>

<p>on .aspx page i take directive of OutputCache as </p>

<pre><code>       &lt;%@ OutputCache Duration ="1" NoStore ="true" VaryByParam ="*" %&gt;
</code></pre>

<p>this keeps my page to cache for 1 second. If another page make request within 1 seconds that page in cache is return even though it is of another user . </p>
