Is it possible to have route like this : www.MyDomin/AnyPage www.MyDomin/AnyPage1 and so on ? Instead of www.MySite/MyController/AnyPage
Without specifying the controller?
Is it possible to have route like this : www.MyDomin/AnyPage www.MyDomin/AnyPage1 and so on ? Instead of www.MySite/MyController/AnyPage
Without specifying the controller?
Well you could define the following route:
routes.MapRoute(
"Default",
"{page}",
new { controller = "Home", action = "Index", page = UrlParameter.Optional }
);
Now all that's left is have the controller action to which this would map:
public class HomeController: Controller
{
public ActionResult Index(string page)
{
...
}
}
Yes it is. Edit your routes in the Global.asax file, for example:
routes.MapRoute(
"MyTerrificRoute",
"{action}",
new { controller = "MyController", action = "Index" }
);