ASP.NET MVC

Introduction To ASP.NET MVC

Introduction to ASP.NET MVC

In this article, we will discuss ASP.NET MVC. MVC stands for Model-View-Controller and it is a framework for developing web applications which have become so popular these days. Earlier developers would go for ASP.NET to create a web application, MVC is an extension to it.

Why MVC?

The basic need of introducing MVC was to make complex application development easy as it takes time to develop a complex application in ASP.NET. MVC is a lightweight framework as compared to traditional ASP.NET Web Forms. The purpose of MVC is to separate the content from the presentation and data processing from the content. One main thing is that MVC has separate the view from the code i.e., unlike Web Forms where “*.aspx” is attached to “*.aspx.cs” here in MVC View is a separate entity entirely.

ASP.NET MVC moves around three basic concepts:

  • Model
  • View
  • Controller

Model: Model is a part of the application which implements the logic for the application. It is used to retrieve and store data in a database. It is also used for business logic separation in the application. It contains the classes.

Example:

public class Order
    {
        public string OrderId { get; set; }
        public int CustomerId { get; set; }
    }

Here { get; set; } is the same like getter and setter in android if you are familiar with. It will get the value from the controller and set it in a particular variable.

View: View is a component that forms the application’s UI. In MVC we use Razor Syntax. The extension of the view has “*.cshtml” instead of “.aspx” which was used in ASP.NET.

MVC view can contain basic HTML, javascript and C# code also.

@{
    string title = "Index";
}

The C# code starts with @ sign in the view and we must have to specify the curly braces {  }

Controller: Controller is an intermediate between the View and Model. All the user interaction is done through Controller only. It controls the user interaction with the application. All the controller names end with Controller like HomeController

Example:

public ActionResult Home()
{
     return View();
}

 

Faisal Pathan

Faisal Pathan is a founder of TheCodeHubs, .NET Project Manager/Team Leader, and C# Corner MVP. He has extensive experience with designing and developing enterprise-scale applications. He has good skills in ASP.NET C#, ASP.NET Core, ASP.NET MVC, AngularJS, Angular, React, NodeJS, Amazon S3, Web API, EPPlus, Amazon MWS, eBay Integration, SQL, Entity Framework, JavaScript, eCommerce Integration like Walmart, Tanga, Newegg, Group-on Store, etc. and Windows services.

Share
Published by
Faisal Pathan

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

3 years ago