Posts

Showing posts from December, 2019

Using Model Binders in ASP.NET Core

Image
In this post we will discuss Model Binders in ASP.NET Core applications.  ASP.NET Core is a unified story for  building Web UI using Razor Views and Web APIs. Web UI can be rendered using PageModel class (like we have Page class in WebForms) and Controllers (like MVC Controllers).  The Razor pages, Controllers (MVC and Web API) works with data that comes from various HTTP requests. The data may be posted using HTTP Body, Route data values, Form Fields. When data is received from such variations then writing code to read such data and map this data with .NET CLR type on server-side is tedious and complex job. The Model Binding is used to simplify this complexity. Model Binding automates the process of mapping the data to .NET CLR types. The Model Binders provides following features It retrieves data received from Form fields, Http Body, Route parameters and query strings.  The received data is provided to controllers as method parameters. The data is further c...

Using Session State in ASP.NET Core

Image
In this post we will discuss the session management in ASP.NET Core applications. If you already have knowledge of ASP.NET Web Forms or ASP.NET MVC, then you must be knowing the Session state as a concept. We always use a statement as "Web applications needs state management", what this really means? A simple answer here is that an HTTP protocol is stateless for performance reason. The reason behind this is that every HTTP request to the web server is separate  and server does not link these requests to each other. There could be multiple HTTP requests as web server process them all.   So for web applications it becomes necessary that we should use server-side state management to maintain the posted data to the web server.  The Session state plays an important role in web applications. Session state is maintained by the web server in  its own memory.  Session state uses store maintained by the application to  persist data across requests by the c...