Click here to Skip to main content
16,016,570 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
i have a snippet that a session has numeric content nd it incrise to 3 but when it receive to 3 it send to client.this session must time out in 1 minuet but until the session is not time out the program work correctly but when the session is expired and new session want create i get system.invalidoperationexception . i check session if its expierd i creat a new but when i want create new session i get system.invalidoperationexception if i select adress bar and reload page new session create but when i use window.location.reload() in client side for refresh my problem dont solve.i use history.go(0) and other method but dont work.whats the problem????
its my code :

C#
string ip = HttpContext.Current.Request.UserHostAddress;


HttpContext failuser = HttpContext.Current;
failuser.Session.Timeout =1;
if (failuser != null)
{
    if (failuser.Session[ip] != null)
        failuser.Session[ip] = (int)failuser.Session[ip] + 1;
    else
        failuser.Session[ip] = 1;

    //
    retval = failuser.Session[ip].ToString();
    if ((int)failuser.Session[ip] > 2)
    {

        retval = "!";

    }
Posted
Comments
behrad110 2-Sep-12 9:51am    
Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"

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