As I was trying the Spark View Engine as an alternative for the WebForms View Engine inside ASP.NET MVC, I first didn’t succeed in using HtmlHelpers inside my views.
The problem was easy to fix. I forgot that the HtmlHelpers are in a seperate namespace. After adding the correct namespace ‘System.Web.Mvc.Html’ to the SparkSettings my views finally compiled.
1: var settings = new SparkSettings()
2: .SetDebug(true)
3: .AddAssembly("SparkDemo")
4: .AddNamespace("System")
5: .AddNamespace("System.Collections.Generic")
6: .AddNamespace("System.Linq")
7: .AddNamespace("System.Web.Mvc")
8: .AddNamespace("System.Web.Mvc.Html") ;
9:
10: ViewEngines.Engines.Add(new SparkViewFactory(settings));