I am trying to render a simple view with the TinyWeb framework and Spark view engine.
Enviroment is Visual Studio 2011 developer preview & .net 4.5
Rendering a template with no model binding works fine.
However when I bind a model then it no longer works.
I get this error:
The name ‘Model’ does not exist in the current context.
Handler:
public class IndexHandler
{
Route route = new Route("/");
public IResult Get()
{
var model = new { message = "Hello World" };
return View.Spark(model, "Views/base.spark");
}
}
View:
<html>
<head>
<title>This is a test</title>
</head>
<body>
<p>${Model.message}</p>
</body>
</html>
You’re using an anonymous object which as far as I am aware will not work, you can either use a full model class or a dynamic object.
And then have
<viewdata model="MyModel">in the view or,And then specify
<viewdata model="dynamic">in the view.