Why HTTP is called stateless protocol?
Http is called stateless protocol because each user request for a page is served without storing the previous request. All the request are treated differently. So after rendering it has no clue of the previous request. It doesn't maintain any state or session by its own.
We may see this with a help of an example.
In our example i will input my name and blog name in two textboxes. After that when i click save button i will store these in two variables and when the restore button is pressed it should restore the value from these variables. Lets see what happens.
Design
Code Behind
You may click the Content tab to see all the posts that i will cover in this tutorial for easy navigation.
In our example i will input my name and blog name in two textboxes. After that when i click save button i will store these in two variables and when the restore button is pressed it should restore the value from these variables. Lets see what happens.
Design
Code Behind
Output
After clicking save button:
After clicking restore button:
Surprise.....!! After clicking restore button then also the textboxs are blank. This is because the http protocols are stateless. So the variables used in the program(i.e. name and blog) cannot retain their values after button click.
So to solve this we have many techniques which will be discussed in the upcoming post.
No comments:
Post a Comment