I'm working with an ASP.NET MVC site which will use a CMS controller for all pages of the site except for the home page. Here's the idea:
Home controller:
CMS Controller:
This page lists some options on how to set up a default page routing:
I guess one other option is to just use one controller with some logic that detects the home page case, but that seems to be fighting the concept.
How do you recommend setting up a specific route for the site home page?
www.site.com can be handled by an root map route
routes.MapRoute(
"Root",
"",
new { controller = "Home", action = "Index", id = "" }
);
Put the following in page load of Default.aspx
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
This rewrites the request to root and handled by the map route above.
BTW, you can actually find the code from the MVC template project.
If hosting on IIS7 integrated mode, I suggest just getting rid of default.aspx. As I understand it, it's only necessary for activation on IIS6 and IIS7 classic mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With