Getting Started With ASP.NET MVC

Getting started with ASP.NET MVC

If you’re wondering how to jump into the fun world of Web Development, ASP.NET MVC is the first thing you might think of learning. While many are familiar with ASP.NET, few know about MVC. Some think that it might be some lethal programming language while some think of it as a software. Few might think that it is some pizza flavor. I thought the same before I started learning it. Here, in this blog, I’ll tell you all about MVC and what you need to learn is ASP.NET MVC today. Are you ready?

What is MVC?

MVC is nothing but a design pattern. Think of mind maps or control flow diagrams. You made them for your understanding and analyzing the flow. Similarly, Web made an MVC pattern for its understanding. This handles everything in a more symmetrical way and eases our work. I hope you’ve realized that it’s not a pizza flavor. 

What is ASP.NET?

ASP.NET is a framework. MVC is its Design Model. Now, what is a Framework? It is like a Workspace. We all need some particular environment or Workspace to work in. For example, I prefer a silent environment for my work. You may prefer a different one. Similarly, every Web page, Web Application or Website need a particular environment to work in, and ASP.NET is this framework. There are many others as well. Framework is a combination of libraries and libraries are made up of classes.

Understanding MVC

M: Model-àData Layer (databases, classes)

V: View à HTML, CSS, JAVASCRIPT

C: Controllerà Logic layer (Brain )

Before giving you the concept of Models, Views and Controllers, I would first like to explain how your request goes to the Browser.

 

Whenever you hit a URL, the request goes to the Server and the response is given back. Now, you should know that there are Browser native languages (HTML, CSS, JAVASCRIPT, XAML), which a Browser can understand and there are some languages that the Browser is unable to understand. For understanding the language, the Browser needs a Server. This converts non native languages into the Browser native languages. It acts similarly like a Translator.

What happens in MVC?

Now, in MVC, when you hit a URL, your request goes to Controller first, i.e. the brain. It decides where to go i.e. whether to return the view directly or go to Models. In the case of Models, the database is involved and the data is retrieved through the database. Thus, it is given the name Data Layer. The separation of concerns is done so beautifully.
 
For example, there is a simple Web Application that take two numbers from the users and returns its sum. In this case, Controller will contain all the code (logic). View will contain everything that the users will see.

Now, if you have to store the value of addition first and then retrieve it, then you will need to add Models. Obviously such kind of Web Application doesn’t exist but I have given this example only to explain the concept for you

You’ll get a better understanding, when you start getting your hands dirty. In the next article, I’ll show you how to make your first ASP.NET MVC Application practically.