Classic Mode MVC Routing
Hello, I am new to SiteFinity and I am looking to build out a new site in Classic MVC mode. I want to leverage all of the SiteFinity content creation & management, workflows, etc., but I need very tight control over the markup and it needs to be easily accessible, like in a standard MVC project. Based on what I've been able to find, this seems pretty straightforward aside from a couple routing issues.
The issue I am having now is that I want all pages to be in classic mode and I want the initial page to accessible via the site root (example: "http://www.example.com/" should drive to my controller & view), instead it appears that the site index page is being captured by the SiteFinity routes. Is there any way to get my classic MVC route to be picked up as the index of the site?
Thanks
Anyone?
Is there any way to insert a default route into the SiteFinity route table, so that I could have the default root of the site (e.g. - "http://www.example.com") point to my custom controller and views? This has to be available somewhere.
Thanks
Hello Mike,
This could be done by registering the MVC controller under root of the project:
Bootstrapper.MVC.MapRoute(
"Classic"
,
"action/id"
,
new
controller =
"MyMvc"
, action =
"Index"
, id = (
string
)
null
);
Ok, thanks for the reply. How exactly would I add this redirect to override the default sitefinity homepage?
Hello Mike,
You have several options to achieve this.
1. You can make a custom widget, which will redirect to the controller's action and place it on the home page.
2. Attach to the begin request event of the bootstrapper and redirect, for example:
protected
void
Bootstrapper_Initialized(
object
sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)
if
(args.CommandName ==
"Bootstrapped"
)
this
.BeginRequest +=
new
EventHandler(Application_BeginRequest);
protected
void
Application_BeginRequest(
object
sender, EventArgs e)
if
(Request.Url.ToString() ==
"http://mysite/"
)
Response.StatusCode = 301;
Response.Redirect(
"http://mysite/index"
);