ASP.NET Fundamentals covers basic topics of ASP.NET Framework such as Session, Cookie, HTTP Handler, HTTP Module, Forms Authentication, Caching, Exception Handling, ASP.NET Request Processing etc.
ASP.NET is a framework developed by Microsoft to build dynamic web applications. There are two programming models to develop web applications using ASP.NET.
Both programming models use ASP.NET on the top of that.
ASP.NET is also a part of Microsoft's .NET Framework. We can write ASP.NET Applications code in any .NET Framework supported language i.e. C#, J#, F#, VB etc.
ASP.NET applications can only be hosted under IIS Server which is available on Window Operating Systems only.
Microsoft has now moved it's further development from this traditional .NET Framework (Windows only) to new .NET Core, which is Cross Platform (supporting Windows, MAC OS, and Linux) framework to develop software applications i.e. Desktop, Web, Console, Mobile Applications.
Sessions are basically server variables that are used to store information on Server.
Session in ASP.NET enables you to store information on server & access that stored information on your sub-sequent web-requests.
HTTP is a stateless protocol, it means every web-request is a new web-request in itself. It does not hold or preserve previous request data. So, Sessions provides us a way to identify the user from on the subsequent web requests.
How to set a value in session in C#:
Session["Email"] = "firstname.lastname@example.org";
How to retrieve the stored value from the session:
string email = Convert.ToString(Session["Email"])
I have covered only basics. You should also study below advanced topics related to Session:
An HTTP Cookie is a piece of data that is stored on the user's browser. Whenever you make a web-request, all the cookies associated with the domain are sent with the web- request.
On the server, we can access those cookies & read values from them. Hence, cookies help us in maintaining state by storing data on client's machine.
You can add a cookie in ASP.NET in following way:
Response.Cookies.Add(new HttpCookie("Email", "email@example.com"));
To read the cookie, you can use below syntax:
string email = Convert.ToString(Request.Cookies["Email"]);
State Management is a technique in ASP.NET to maintain states. There are following ways in ASP.NET to maintain states:
Explain in detail what is it? When can we make custom one? Why to use it?