Spark-View-Engine with ASP.NET MVC2

Posted by Ben on Stack Overflow See other posts from Stack Overflow or by Ben
Published on 2010-01-14T15:24:01Z Indexed on 2010/04/10 7:13 UTC
Read the original article Hit count: 942

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);
    }
}

}

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about mvc