Introduction
Before to start over to know about MVC complete Life Cycle, it is mandatory to add required namespaces in web.config which are automatically added when we add MVC package in our MVC application. We all know the basic behaviour of MVC is based on HTTP requests. In my recent article, I have already explained how to create amazing charts using MVC.I have provided all necessary MVC life cycle steps here.
<namespaces>
<add namespace="System.Web.Helpers">
<add namespace="System.Web.Mvc">
<add namespace="System.Web.Mvc.Ajax">
<add namespace="System.Web.Mvc.Html">
<add namespace="System.Web.Optimization">
<add namespace="System.Web.Routing">
<add namespace="System.Web.WebPages">
</namespaces>
<add namespace="System.Web.Helpers">
<add namespace="System.Web.Mvc">
<add namespace="System.Web.Mvc.Ajax">
<add namespace="System.Web.Mvc.Html">
<add namespace="System.Web.Optimization">
<add namespace="System.Web.Routing">
<add namespace="System.Web.WebPages">
</namespaces>
1) We send our request through HTTP to our server.
2) Then request goes through our MVC routing.
3) Our web request sends through Global.asax file where all routes are registered under this file, according to our MVC request then request is forwarded according to matching route.
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); //ModelBinders.Binders.DefaultBinder = new Microsoft.Web.Mvc.DataAnnotations.DataAnnotationsModelBinder(); AreaRegistration.RegisterAllAreas(); }
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); }
public ActionResult Index() { return View(); }
@{
ViewBag.Title = "Home";
}
<!DOCTYPE html>
<html lang="en">
<head> <meta charset="utf-8" />
<title>@ViewBag.Title</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
</head>
<body> <div> Welcome to Technology Crowds </div> </body>
</html>
<!DOCTYPE html>
<html lang="en">
<head> <meta charset="utf-8" />
<title>@ViewBag.Title</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
</head>
<body> <div> Welcome to Technology Crowds </div> </body>
</html>
Post A Comment:
0 comments: