Renaming a controller ?

Sunny.Sagar
Posted by Sunny.Sagar under ASP.NET MVC category on | Points: 40 | Views : 619
ROUTECONFIG CODE

  public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(
name: "MyCustomRoute",
url: "MyEmployees/{action}/{id}",

defaults: new { controller = "PersonalDetail", action = "Create",
id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}


A controller can’t be renamed like an action method, however the route can be changed so that you do not need to stick with the url that is directly related with the controller name

Comments or Responses

Login to post response