Spark-View-Engine with ASP.NET MVC2
- by Ben
How do you modify a ASP.NET MVC 2.0 project to work with the Spark View Engine?
I tried like described here:
http://dotnetslackers.com/articles/aspnet/installing-the-spark-view-engine-into-asp-net-mvc-2-preview-2.aspx
But somehow it still tries to route to .aspx files.
Here the code of my global.asax:
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
protected void Application_Start()
{
SparkViewFactory svf = new SparkViewFactory();
PrecompileViews(svf);
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
public static void PrecompileViews(SparkViewFactory svf)
{
var controllerFactory = svf;
var viewFactory = new SparkViewFactory(controllerFactory.Settings);
var batch = new SparkBatchDescriptor();
batch
.For<HomeController>()
.For<AccountController>();
viewFactory.Precompile(batch);
}
}
}