Header Ads

Introduction of MVC(Model View Controller)

What is MVC?

MVC means Model View Controller. This is a programming paradigm that helps you to better separate the different layers of your project.

Model: the model is the set of elements that allow you to manipulate your data (XML, SQL, etc..).

View: The view is the end result you want to achieve (the web page).

Controller: The controller manages the various queries. This is the controller that will search or update the data and send it to the view.

ASP.NET MVC

ASP.NET, as long as you are interested in Microsoft technologies, everyone knows. MVC is a programming paradigm well known and widespread. ASP.NET MVC is a mix of both worlds.
The objective is to take a maximum of thing of ASP. NET and put them in a MVC framework.
This framework has been in development for quite some time and was officially launched at MIX09 in Las Vegas.

ASP.NET MVC VS ASP.NET

For many people the choice is not difficult. Are you a seasoned winform developer? Then you will probably choose ASP.NET. You want to manipulate many form (Web Application Data Management)? You will go also to ASP.NET. You want full control over the HTML? Then you will go faster to ASP.NET MVC. You are accustomed to MVC paradigm ,then you will go to ASP.NET MVC.
Choose between ASP.NET and ASP.NET MVC should not be an ideological choice. This is based on your project that you need to choose one or the other. Below you will find some items that you should consider before choosing:

- Your application can handle many forms?
- Will you manage inevitably the features of viewstate ?
- You need the user controls present in ASP.NET?

Then you should choose ASP.NET.

- Need a good SEO through beautiful URLs?
- Need more control over the HTML?
- Want to easily test your application?
- Need to integrate a lot of JavaScript?

Then you should choose ASP.NET MVC.

Operation of ASP.NET MVC

A host can run ASP.NET MVC by copying three DLLs in your BIN directory
Please note: To avoid make copy and paste yourself and having correctly reference the DLL in the Web.config, you can go into the properties of the DLL and call a local copy.
These DLLs contain the elements necessary for proper functioning of ASP.NET MVC. It includes a http module: UrlRoutingModule.
This HTTP module analyzes the request and see the pattern that best match in the different routes that we have defined in Global.asax.

routes.MapRoute ( "Default", / / Route name "{controller} / {action} / {id}", / / URL with parameters
new {controller = 'Home ", action =" Index ", id =" "} / / Parameter defaults );


Typically, if the url looks like: http://www.mysite.com/Home/Index/1 then Http Module will find a route that matches. It will then return an instance of the controller that corresponds (here it is HomeController).
This is the controller's Execute method which is called.
If the http module does not find anything then it goes in classic ASP.NET version.

Note: IIS normally need to know the file extension in order to function properly. In the case of ASP. NET MVC, there is no extension because the URL is formatted. If you go in IIS you will see that the extension .Mvc has been added and validated.

1 comment:

Powered by Blogger.