The Deployment of MVC Application is much straight fwd.. as far as Virtual directory and Mapping of our Application is concern.
The only twist while deploying the MVC Application because we never have the Extension of Pages while serving to user . This is some what like this “Scheduling/Index/24” etc.
Follow the following steps :
Creating First MVC Application :
Now just let the Application Open into VS and Hit run. Here we can see the very clean URL in browser and application by default displaying the Home Page of Application.
Now we will Add a new Page in the Application. There is nothing much complicated in doing so. For that we will first add a “Controller” who is actually responsible for the navigating and displaying a particular “View”.
After adding this Scheduling Controller, we are going to add another “View” called Scheduling which will be controlled by Scheduling Controller we have just added in our Application. For that just open the Scheduling Controller and right click and click on “Add View”.
Now to run this Scheduling View and see output, we need to place an Action Method for this View in Scheduling Controller which will return this Scheduling View. Here we need to take care of one thing is that , the name of Action Result Method should be same as that of View we have Added . In our case it is “Scheduling” and “Index” so we have added the method with the name “Scheduling”.
If we have mentioned a different name in to the ActionResult then it will go and Search this View Name in to the Shared Folder and if it is not even there then an Error Page is displayed from Shared Folder.
This Clean and Clear URL all is given by the “Route” which is defined in Global.asax file. User can define his/her choice of URL Route and the page will get displayed accordingly as shown in below screen shot…
MVC is a framework methodology that divides an application’s implementation into three component roles: models, views, and controllers.
One of the benefits of using a MVC methodology is that it helps enforce a clean separation of concerns between the models, views and controllers within an application. Maintaining a clean separation of concerns makes the testing of applications much easier, since the contract between different application components are more clearly defined and articulated.
One of the most Important feature of MVC :
It includes a very powerful URL mapping component that enables you to build applications with clean URLs. URLs do not need to have extensions within them, and are designed to easily support SEO and REST-friendly naming patterns.
For example, I could easily map the /products/edit/4 URL to the “Edit” action of the ProductsController class.