Model View Controller ASP.NET MVC Pattern

0
327
Model View Controller ASP.NET MVC Pattern

In the previous I have explained how to Creating New ASP.NET MVC Project Visual Studio 2019. Now we are going to understand the MVC structure or model view controller in ASP.NET MVC. When I was just about to start with .NET I have read many articles and found nothing informative as a beginner. Because I didn’t know about development pretty much & now I’m near to be master in my own thoughts (May be).

For More depth knowledge have a visit on .NET Official Site

It’s really simple to understand MVC, it’s not about just .NET it will be applicable to any cutting edge web technology. In MVC we just isolated each concern (usage).

There are three aspects in web development on which MVC is based.

Understand Model

Model which is nothing but a class. A simple class holding properties (attributes). When I was doing study in university I just came to know only few datatypes like (int, string, bool) etc. But you can create your own user-define datatypes too which we are going to learn soon. You can create properties of your own datatypes, you can create complex class which will based on inheritance,  abstraction, static methods and so on complexes things. It’s hard to understand first but after few days practice make you enough stronger that, it will be really easy for your. In short if you need to get data and want to update data you need a path (medium) which will help you to transfer data and Model is the best medium here.

Subscribe YouTube For More Videos | Video is in Hindi – URDU

Understand View

It is a page holding some HTML code. In case of different server side languages it may have server side code too, like in .NET you can use Razor (server side code in .NET) and dynamic properties in View too for extension of features. In ASP.NET view have extension of (.cshtml) which means you can also write C# code inside these pages. Which gives a huge favor to C# developers to get started with ASP.NET Framework. So finally we have conclusion here about View is that, it holds font-end or client side code. From which user have to interacted like (dropdowns, input fields, progress bars, date time picker) etc.

Subscribe YouTube For More Videos | Video is in Hindi – URDU

Understand Controller

It’s also the C# based class but in this we are going to write server side code. A code which will be responsible for the functionality of whole application. Like the path where a page exist and from where data will be released and processed. As name reflects it’s tasks such as Control the flow of model & view. A controller contains actions which are just member function (methods). If you are familiar with object oriented programming, then you also get to know that classes are composition of data member (properties) and data method (functions).

Key Benefits of ASP.NET MVC

Same case is here, we will call data method (actions). Each action have their own return type such as ActionResults which means if you will call this action it will return you a View (A page of cshtml). So it’s upon you, what you want to return when user will call your action. If you want to transfer any data you can use model inside your controller action to process information and return it to view so that user can interact with that.

Subscribe YouTube For More Videos | Video is in Hindi – URDU

Conclusion

Here you have learned a brief about the Model View Controller in ASP.NET MVC aspect. This is what I have learned after practiced alot. If you found any flaw in this piece of words (knowledge) then must share it will me so that I can improve the quality of content.

Creating New ASP.NET MVC Project Visual Studio 2019

MVC is just a pattern and way to develop application with separation of concerned. So each entity will be independent and reusable. Remember MVC is purely based on OOP. You can create your own patters too like you have haired about MVVM etc that are same as MVC but with some different aspect of programming.