How to modify the session variable inside the asp.net webmethod

Bhupendra Shukla

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;
    }
Devesh

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;      

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

session modify from webmethod

From Dev

Jqgrid with asp.net [WebMethod] inside aspx page Issue

From Dev

How to transfer session variable from classic asp to asp.net?

From Dev

How to access the Session in ASP.NET Core via static variable?

From Dev

How to instantiate an ASP.net (MVC 5) Session Variable?

From Dev

How to format JSON for asp.net webmethod that takes class parameter

From Dev

How to code ASP.NET WebMethod for Ajax Call

From Dev

How to pass json string to webmethod c# ASP.NET

From Dev

how to call a c# webmethod on mouseover of linkbutton in asp.net?

From Dev

asp.net WebMethod not working

From Dev

ASP.NET JSON & Webmethod

From Dev

ASP.NET ternary operator on the Session variable

From Dev

ASP.NET ternary operator on the Session variable

From Dev

How to modify the XML of a WebMethod request generated by JAXWS

From Dev

How to store a variable inside a JavaScript session cookie?

From Dev

How to pass session variable inside class

From Dev

call asp.net webmethod in windows project

From Dev

asp.net / JavaScript ClientSide CustomValidation WebMethod

From Dev

asp.net call asynchronous webMethod with Jquery

From Dev

why datetime is not localized in asp.net webmethod?

From Dev

asp.net web forms [WebMethod]

From Dev

Set Session object inside a WebMethod (using EnableSession = true) not storing value

From Dev

Modify a variable inside a function

From Dev

How to resolve ASP.Net "Input string was not in a correct format" error when using session variable

From Dev

asp.net - how to set a session variable as soon as a new user visit any web page ?

From Dev

how to store Gridview Boolean value in session variable and show another page in asp.net

From Dev

How to set a asp:DropDownList SelectedValue to a Session Variable?

From Dev

How to set a asp:DropDownList SelectedValue to a Session Variable?

From Dev

How can I send complex JavaScript object to ASP.net WebMethod?

Related Related

  1. 1

    session modify from webmethod

  2. 2

    Jqgrid with asp.net [WebMethod] inside aspx page Issue

  3. 3

    How to transfer session variable from classic asp to asp.net?

  4. 4

    How to access the Session in ASP.NET Core via static variable?

  5. 5

    How to instantiate an ASP.net (MVC 5) Session Variable?

  6. 6

    How to format JSON for asp.net webmethod that takes class parameter

  7. 7

    How to code ASP.NET WebMethod for Ajax Call

  8. 8

    How to pass json string to webmethod c# ASP.NET

  9. 9

    how to call a c# webmethod on mouseover of linkbutton in asp.net?

  10. 10

    asp.net WebMethod not working

  11. 11

    ASP.NET JSON & Webmethod

  12. 12

    ASP.NET ternary operator on the Session variable

  13. 13

    ASP.NET ternary operator on the Session variable

  14. 14

    How to modify the XML of a WebMethod request generated by JAXWS

  15. 15

    How to store a variable inside a JavaScript session cookie?

  16. 16

    How to pass session variable inside class

  17. 17

    call asp.net webmethod in windows project

  18. 18

    asp.net / JavaScript ClientSide CustomValidation WebMethod

  19. 19

    asp.net call asynchronous webMethod with Jquery

  20. 20

    why datetime is not localized in asp.net webmethod?

  21. 21

    asp.net web forms [WebMethod]

  22. 22

    Set Session object inside a WebMethod (using EnableSession = true) not storing value

  23. 23

    Modify a variable inside a function

  24. 24

    How to resolve ASP.Net "Input string was not in a correct format" error when using session variable

  25. 25

    asp.net - how to set a session variable as soon as a new user visit any web page ?

  26. 26

    how to store Gridview Boolean value in session variable and show another page in asp.net

  27. 27

    How to set a asp:DropDownList SelectedValue to a Session Variable?

  28. 28

    How to set a asp:DropDownList SelectedValue to a Session Variable?

  29. 29

    How can I send complex JavaScript object to ASP.net WebMethod?

HotTag

Archive