Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. HTTP STATELESS..

HTTP STATELESS..

Scheduled Pinned Locked Moved ASP.NET
sysadminquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rahul83
    wrote on last edited by
    #1

    Hi friends, If I am making my some member variable of a class as a static(say int i),then at each Page Postback i m able to manipulate(say increment) the previous value of i.My Question is whether by making member as a static are we making it to be remember by server during subsequent page requests..if so then how http is stateless.. Warm Regards, Rahul Agarwal

    E S 2 Replies Last reply
    0
    • R Rahul83

      Hi friends, If I am making my some member variable of a class as a static(say int i),then at each Page Postback i m able to manipulate(say increment) the previous value of i.My Question is whether by making member as a static are we making it to be remember by server during subsequent page requests..if so then how http is stateless.. Warm Regards, Rahul Agarwal

      E Offline
      E Offline
      Elizma
      wrote on last edited by
      #2

      Hi, Remember that static members belongs to a class. Therefore whatever you do to it in a class will be remembered for the time that this application is running in it's own session (will not influence another user). But the problem is it will be reset when the application close. Regards, Elizma

      R 1 Reply Last reply
      0
      • E Elizma

        Hi, Remember that static members belongs to a class. Therefore whatever you do to it in a class will be remembered for the time that this application is running in it's own session (will not influence another user). But the problem is it will be reset when the application close. Regards, Elizma

        R Offline
        R Offline
        Rahul83
        wrote on last edited by
        #3

        Thanks..But I tried something like this.. static int i; protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e) { i=i+1; TextBox1.Text=i.ToString(); } For each Button Click event, the value of "i" is incremented and displayed in the TextBox. I have clicked the button 5 times and the text box shows 5 in it. At this moment,when I opened another browse , copy - paste the same url and I tried to click the button, it shows "6" in it. Then why it working when i am opening the page in new browser window..My question is whether making it static will make it remember at server during subsequent page postbacks or not? Warm Regards, Rahul

        S 1 Reply Last reply
        0
        • R Rahul83

          Thanks..But I tried something like this.. static int i; protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e) { i=i+1; TextBox1.Text=i.ToString(); } For each Button Click event, the value of "i" is incremented and displayed in the TextBox. I have clicked the button 5 times and the text box shows 5 in it. At this moment,when I opened another browse , copy - paste the same url and I tried to click the button, it shows "6" in it. Then why it working when i am opening the page in new browser window..My question is whether making it static will make it remember at server during subsequent page postbacks or not? Warm Regards, Rahul

          S Offline
          S Offline
          ShuklaGirish
          wrote on last edited by
          #4

          according to me value of static variables is maintained at server till that variable is not assigned null value or u need to call the destructor to relase the memory occupied by that variable.Else server will maintain the varaibles value even if u close the application from client end.

          1 Reply Last reply
          0
          • R Rahul83

            Hi friends, If I am making my some member variable of a class as a static(say int i),then at each Page Postback i m able to manipulate(say increment) the previous value of i.My Question is whether by making member as a static are we making it to be remember by server during subsequent page requests..if so then how http is stateless.. Warm Regards, Rahul Agarwal

            S Offline
            S Offline
            SimulationofSai
            wrote on last edited by
            #5

            Http is stateless, ASP.NET is not. Http is the communication protocol that helps the browser and the web server talk and exchange HTML. Your ASP.NET website is also an application, but it runs inside an application domain within IIS.

            SG

            R 1 Reply Last reply
            0
            • S SimulationofSai

              Http is stateless, ASP.NET is not. Http is the communication protocol that helps the browser and the web server talk and exchange HTML. Your ASP.NET website is also an application, but it runs inside an application domain within IIS.

              SG

              R Offline
              R Offline
              Rahul83
              wrote on last edited by
              #6

              Thanks for answer..so static variable will be maintained at server during subsequent page requests..right?

              S 1 Reply Last reply
              0
              • R Rahul83

                Thanks for answer..so static variable will be maintained at server during subsequent page requests..right?

                S Offline
                S Offline
                SimulationofSai
                wrote on last edited by
                #7

                That's right.

                SG

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups