Introduction to ASP.NET MVC
ASP.NET MVC is a UI technology based on Model,View,Controller design pattern. In the MVC pattern use separate UI code in to distinct components.You have model,view and controller
Model contain data to be displayed and some associated logic. The Controllers are responsible for recieving a request and figuring out what to do, they often build the model and they select a view to build the model. The view is only responsible for taking the model from the controller and producing the html that you see in the browser. Each component has distinct responsibilities
How ASP.NET MVC works?
When i make a request to the browser for example localhost:49169 the runtime will looking for a controller to process this request. MVC is working on the basis of routing logic. Routing is something configured on the start of the application that is inside Global.asax.
Route specify a pattern that the runtime match against the incoming URL.
The method RegisterRoutes() configured in the Application_Start method of a Global.asax file which is responsible for handling the incoming URL.We can specify the default Controller and action inside the register routes method.
Whenever i making a request for example localhost:49169 without specifying the controller and action in the url the routing mechanism of ASP.NET MVC takes the default controller and action such as Home and index. That means i can make request to localhost:49169/home that arrives the homepage and i can make request to localhost:49169/home/index that arrives the same page. If i am try to specify that doesn’t exist for example localhost:49169/hello and there is no hello controller and i get back an Http 404 error like below.