I want to remove Controller
named Home
from url
when user clicks on About
and Contact
pages in ASP.NET MVC sample application
. I tried this but it is giving me a 404 error.
routes.MapRoute("Home", "{action}/{id}",
new { controller = "Home" });
When i remove this all works perfectly.
Note I want to remove Controller name only when Controller is Home. Other Controller should remain same.
Further I kept the code in Route.Config
file above
routes.MapRoute("Home", "{action}/{id}",
new { controller = "Home" });
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Required Result
abc.com/Home/About should shown as abc.com/About
abc.com/Home/Contact should shown as abc.com/Contact