Map Routes using Route Class in MVC
In MVC application, we can register routes in
RouteCollection using RouteConfig. This RouteConfig is called
using Application_Start of application.
RouteConfig is configured as below
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "ProgramConfigEditor", action = "Index", id = UrlParameter.Optional }
);
We can register route of the application using Route
Class as below. After creation of Route collection, it will move to MvcRouteHandler object.
Route route = new Route("{controller}/{action}/{id}",
new RouteValueDictionary { { "controller", "ProgramConfigEditor" }, { "action", "Index" }, { "id", "1" } }, new MvcRouteHandler());
routes.Add(route);
Comments
Post a Comment