Setup folder structure:
Download and put the asp.net mvc dll’s in mvc folder and spark dll’s in spark folder.
Create a new asp.net application not a mvc application just a standard asp.net application. This means you will not get the mvc helpers for creating controllers and views but that’s not a massive loss and has the advantage that you don’t need the asp.net mvc installed if you open the solution on another machine.
Change content of Default.aspx to:
The default.aspx placeholder is required to allow the asp.net routing to work.
Delete the code behind files for Default.aspx (Default.aspx.cs, Default.aspx.designer.cs) they are not needed.
Add references to the Spark.dll and Spark.Web.Mvc.dll located in the libs folder.
Add references to asp.net mvc System.Web.Routing.dll, System.Web.Abstractions.dll, System.Web.Mvc.dll
Add spark to the web.config:
</sectionGroup>
<section name=”spark” type=”Spark.Configuration.SparkSectionHandler, Spark”/>
</configSections>
Debug true shows compilation errors when rendering views.
Add routing to httpModules section of web.config:
Add a application.cs which creates the routes and registers the spark view engine:
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using Spark.Web.Mvc;
namespace Web
{
public class Application
{
public void RegisterRoutes(IList
public void RegisterViewEngine(IList
Add a global.asax with the following code behind.
using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace Web
{
public class Global : HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
var app = new Application();
app.RegisterRoutes(RouteTable.Routes);
app.RegisterViewEngine(ViewEngines.Engines);
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
string path = Request.AppRelativeCurrentExecutionFilePath;
if (string.Equals(path, “~/default.aspx”, StringComparison.InvariantCultureIgnoreCase) ||
string.Equals(path, “~/”))
{
Context.RewritePath(“~/Home”);
}
}
}
}
Create content, controllers and view folders in the root of the asp.net project:
Create a shared folder in the views folder with a _global.spark file this will be used to share come code with all views.