Model Binding Example
The data coming from HTTP requests has been bound to the view here.

Model binding here is used by calling the data for a particular id in the query. ASP.NET will take out the id field and provide it as an argument to the action method.
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
public Action Index(int id)
{
return View(repository[id]);
}
More illustration:
User.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Temp.Models
{
public class Student
{
public int _id { get; set; }
public string _name { get; set; }
public string _email { get; set; }
public string _contact { get; set; }
}
}
Above is a model that includes student data containing unique IDs, name, email and contact. let us now create a controller.
User.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Temp.Controllers
{
public class Student: Controller
{
// GET: Students
public ActionResult Index()
{
return View();
}
}
}
After this, we need to create a view and add the model, name of the view to it, which will create a view for us as below.

Output:

FAQs
-
What are web forms?
A web form is an HTML form that makes the user input the data to be able to send it through the backend. The web forms have enabled user interactions with DOM easily. It is on the view layer of MVC architecture.
-
What is model binding?
This term model binding refers to synchronized changes to be reflected in both the view and the database. In the same way, models can be bound with data objects coming from the backend.
-
How do you manipulate the view using model binding?
Binding form elements to the model then reflecting those changes upon interaction with the DOM is the idea behind manipulating views. Functionalities in the controller can be used to manipulate the DOM.
-
What is the MVC pattern in ASP.NET?
It implies a Model View Controller pattern. This is focused on separating logic to build a web application. The controller holds on to the view; the view displays the content, interaction through the view will lead to change in the database, which again triggers the controller to reflect changes on to the view. This pattern has been popular and used by many web dev frameworks.
-
What is a master page?
Master pages give consistent look and behaviour to all pages in an ASP.NET application. It provides templates, placeholders for the content of all the pages that have a shared layout and common functionality. We can customise and write our own logic in them.
Key takeaways
Congratulations on getting through this article. This article showed how web forms are used with model binding in the ASP.NET framework.
You can also explore many other open-source, server-side web-application frameworks other than ASP.net with the article Top 10 web development frameworks.
Happy Learning!