Click here to Skip to main content
15,895,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below events calling multiple times:
C#
public override SessionStateStoreData GetItemExclusive(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actionFlags) 
{
    return GetSessionStoreItem(true, context, id, out locked, out lockAge, out lockId, out actionFlags); 
}

public override void ReleaseItemExclusive(HttpContext context, string id, object lockId) {
    string tmpQuery = @"UPDATE Sessions SET Locked = 0, Expires = @expires@ WHERE SessionId = '@sess_id@' AND ApplicationName = '@app_name@' AND LockId = '@lock_id@'";

    tmpQuery = tmpQuery.Replace("@expires@", convDate_forQuery(DateTime.Now.AddMinutes((double)(pConfig.Timeout.Minutes))));
    tmpQuery = tmpQuery.Replace("@sess_id@", id);
    tmpQuery = tmpQuery.Replace("@app_name@", ApplicationName);
    tmpQuery = tmpQuery.Replace("@lock_id@", lockId.ToString());

    try
    {
        SessDataAccess.ExecuteNQ(tmpQuery);
    }
    catch (Exception e)
    {
        if (WriteExceptionsToEventLog)
        {
            WriteToEventLog(e, "ReleaseItemExclusive");
            throw (e);
        }
        else
            throw e;
    }
}

Events log:
  • 2/20/2020 1:40:43 PM:GetItemExclusive
  • 2/20/2020 1:40:43 PM:GetItemExclusive
  • 2/20/2020 1:40:43 PM:GetItemExclusive
  • 2/20/2020 1:40:43 PM:GetItemExclusive
  • 2/20/2020 1:40:43 PM:GetItemExclusive
  • 20-02-2020 13:40:43:Initialize
  • 2/20/2020 1:40:43 PM:GetItemExclusive
  • 2/20/2020 1:40:43 PM:ReleaseItemExclusive
  • 2/20/2020 1:40:43 PM:ReleaseItemExclusive
  • 2/20/2020 1:40:43 PM:ReleaseItemExclusive
  • 2/20/2020 1:40:43 PM:ReleaseItemExclusive
  • 2/20/2020 1:40:43 PM:ReleaseItemExclusive
  • 2/20/2020 1:40:43 PM:ReleaseItemExclusive

Can anyone help me on this! thanks in advance.

What I have tried:

I tried to kept logs, how many times it calling
Posted
Updated 20-Feb-20 2:27am
v2
Comments
Richard Deeming 20-Feb-20 8:27am    
tmpQuery = tmpQuery.Replace("@expires@", convDate_forQuery(DateTime.Now.AddMinutes((double)(pConfig.Timeout.Minutes))));

Don't do it like that!

Your code is almost certainly vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]

You need to update your SessDataAccess class so that it doesn't force you to inject parameter values directly into the query.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900