Action in ASP.NET MVC Application

 Here we learn About Models

Models binding is One of the best features of the ASP.NET MVC framework. Models binding maps data in an HTTP request to controller action method parameters. The action parameters may be simple types such as integers, strings, etc. Models binding is the well-designed bridge between the HTTP request and the C# action methods. 

Let's us understand by a simple example

In solution explorer Right-click on the model - click on Add - Click on class.

Model Binder's Graphical flow




Add the required field



Here we learn About Controller Class

  • The controller action method must be public access.
  • It can't be static
  • It must be the return value.
  • It must be defined with a return type.
  • It can be parameterless.
Let's us understand by a simple example

In solution explorer Right click controller - Add - controller                        Here we have different types of templates and most of them autogenerate code.

So, Select MVC5 Controller-Empty. Then you add a controller name













Here we learn About Views

  • A Viwe is a file with .cshtml(forC#) extension.
  • Views are generally returned from the action method of the controller.
  • A View is used to display data using the model class object.
  • The Views folder contains all the view files in the ASP.NET MVC application.



Now our code is ready for run press f5 to see the output.

Post a Comment

0 Comments