Reputation: 32758
I currently have the following route set up:
context.MapRoute("Root", "", new
{
controller = "Server",
action = "FavoritesList",
id = "00C"
}
);
However I would like to change this so the default goes to the following:
/F00C/Home-About#/C01C/Overview
I realize this doesn't map to controllers and actions but is there a way I can just do an internal redirect with the MapRoute to a another href.
Upvotes: 0
Views: 582
Reputation: 4282
If you mean you would like your default page to be that meaning that if someone hits your root / you would like them to be redirected to /F00C/Home-About#/C01C/Overview, then simply assuming you have these routes in global.asax.cs
routes.MapRoute(
"DefaultRedirect", // Route name
string.Empty, // URL with parameters
new { controller = "Home", action = "Redirect" });
routes.MapRoute(
"Homepage",
"F00C/Home-About",
new { controller = "Home", action = "Index" });
You can do this in your HomeController:
public ActionResult Redirect()
{
return Redirect("~/F00C/Home-About#/C01C/Overview");
}
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
EDIT: Forgot to say
You can also just configure a redirect in IIS itself if that is more to your liking, but this way it is part of the application.
Upvotes: 1