SparkViewエンジンでviewdata構造を使用する方法を理解できないようです。コントローラに次のコードがあります。
// Retrieve the project list from the database
var projects = from p in _context.Repository<project>()
orderby p.name ascending
select p;
return View(projects.ToList<project>());
ユニットテストで正しいプロジェクトが返され、非スパークビューが完全に機能したため、このコードは機能します。現在、Spark View Engineに切り替えようとしていますが、構文が混乱しています。補足として、sparkビューエンジンが機能し、.sparkビューを読み取っていることを確認しました。
これが私のlist.sparkビューで使用しているものです:
<h2>Available Projects</h2>
<viewdata model="IList[[project]]"/>
Count: ${model.count}
このビューをレンダリングすると、次のエラーが発生します。
.../List.Spark(3,16): error CS0103: The name 'model' does not exist in the current context
This is referring to the model.count line. Why doesn't this work? I tried passing the project list to the ViewData["projects"] (and replaced model in the spark code with projects) and I get the same error (take out the model.count for projects.count).
This is probably something stupid, but I can't seem to figure this out.
Update:
Well I fixed this. It seems that the MVC2 web.config file created by VS 2010 Beta 2 was bad. I used a MVC2 web.config file created by VS 2010 RC and it now works. Thanks!