ASP.NET Session Management
1.Why is http protocol stateless ?
- Http is called as a stateless protocol because each request sends without any knowledge of that request.
- means once the request sends to the server after responding to that request, the server lost that connection.
In our application, I go to the HomeController and in that First, I sends the request to the index. So let's see:
Here I create a variable that is i=0 and increment that as an i++. And I also put the debug point when I run this first GET request is sent. now we see:
See here the i becomes 0 again. This is the HTTP stateless protocol.
2.What is session variable?
- Session is used to store or save the user data.
- Session stores the data on the server.
3.How to enable session in MVC core?
First we need to add the session service in the Startup.cs file and after that have to use that session as shown below.
But remember if you do not add session service in Startup.cs file then you won’t be able to run the project properly.
4.What is cookies?
- The session uses cookies.
- Cookies is some piece of data which is stored in the browser.
- We can store users related information in cookies.
inspect the cookies :
5.How to make http stateful protocol?
- To make http protocol stateful, we can use session management techniques.
- It uses data coming from previous request in present request.
- It uses same connection for series of client server interaction for limited time.
For more understanding watch below video:
Thank you!!!!!!
No comments:
Post a Comment