3

I have following webmethod where i want to modify the value of the existing Session variable but here inside the webmethod whenever i assign the value to that session variable, the value is not assigning to it.

WEBMETHOD

 [WebMethod(EnableSession = true)]
    public static List<tblCustomerList> CustData(String id)
    {
        Int32 count=(Int32) HttpContext.Current.Session["pgnum"];
        HttpContext.Current.Session["pgnum"] = count++;
        DataGridEntities _dbContext = new DataGridEntities();
        var filteredResult = _dbContext.tblCustomerLists.ToList();
        return filteredResult;
    }
1
  • should not you use the ++count , what do you mean by not assigning Commented Nov 22, 2013 at 7:17

1 Answer 1

5

In your code you should do like this, because count++ will assign the existing value and then increment its value

          HttpContext.Current.Session["pgnum"] = ++count;      
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.