Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing asp.net mvc 2 features with the spark view engine
    primarykey
    data
    text
    <p>I am working with an ASP.NET MVC project which was originally started from the <a href="http://codebetter.com/blogs/karlseguin/archive/2009/04/28/presenting-codebetter-canvas.aspx" rel="nofollow noreferrer">CodeBetter.Canvas</a> project - and I'm trying to move to ASP.NET MVC 2. I successfully upgraded my project using <a href="http://weblogs.asp.net/leftslipper/archive/2009/10/19/migrating-asp-net-mvc-1-0-applications-to-asp-net-mvc-2.aspx" rel="nofollow noreferrer">Eilon's upgrade tool</a>, moved to VS2010 (although not yet to .NET 4).</p> <p>The issue I'm having currently is only occurring when using the spark view engine. Here is the relevant bit of code in my View.spark (strongly typed):</p> <pre><code>${Html.EditorFor(e =&gt; e)} </code></pre> <p>The same bit of code <em>works just fine</em> if I use an .aspx view:</p> <pre><code>&lt;%= Html.EditorFor(e =&gt; e) %&gt; </code></pre> <p>The major point here being "EditorFor" is new in ASP.NET MVC 2 and in my project I can use that helper in an ASPX view but not a Spark view.</p> <p>I've tried <a href="https://stackoverflow.com/questions/1261576/asp-net-mvc-2-0-prev-1-and-spark/1264289#1264289">upgrading Spark to use MVC 2</a> (as well as MvcContrib and Ninject), thinking maybe it was one of those that was freaking out - but so far no luck - I'm still seeing the same behavior.</p> <p>Here is the full error message that is thrown from within Spark's BatchCompiler class.</p> <blockquote> <p>Dynamic view compilation failed. (0,0): warning CS1701: Assuming assembly reference 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' matches 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35', you may need to supply runtime policy c:\inetpub\wwwroot[myproject]\CodeBetter.Canvas.Web\Views[MyEntity]\View.spark(9,16): error CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'EditorFor' and no extension method 'EditorFor' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)</p> </blockquote> <p>Here is the Spark related code in my Global.asax:</p> <pre><code>var settings = new SparkSettings() .AddNamespace("System") .AddNamespace("System.Collections.Generic") .AddNamespace("System.Web.Mvc") .AddNamespace("System.Web.Mvc.Html") .AddNamespace("MvcContrib.FluentHtml") .AddNamespace("CodeBetter.Canvas") .AddNamespace("CodeBetter.Canvas.Web") .SetPageBaseType("ApplicationViewPage") .SetAutomaticEncoding(true); #if DEBUG settings.SetDebug(true); #endif var viewFactory = new SparkViewFactory(settings); ViewEngines.Engines.Add(viewFactory); </code></pre> <p>Also, I am referencing System.Web.Mvc.Html in my spark view as mentioned <a href="https://stackoverflow.com/questions/1081650/cannot-use-html-actionlink-in-asp-net-mvc-spark-files">in another SO answer</a>.</p> <pre><code>&lt;use namespace="System.Web.Mvc.Html" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload