I recall that we briefly mentioned Spark View Engine at the last Tampa ASP.NET MVC Developer Group Meeting. However, we never really showed it in action. We may need to do this for 30 minutes at the next meeting, which is another great open mic night.
Anyway, Lou talks about a new Output Caching feature in Spark 1.1 to help you eliminate WCF, database, or other expensive calls in your ASP.NET MVC Web Applications.
His solution is pretty slick, especially the ValueHolder Class to clean up the views and defer code execution. From the documentation:
public ActionResult Details(int id)
{
var data = new NorthwindDataContext();
ViewData["employeeId"] = id;
ViewData["employee"] = ValueHolder.For(
() => data.Employees.Single(x => x.EmployeeID == id));
return View();
}
and
<
viewdata
employeeId="int"
employee.Value="Employee employee"/>
<
cache key="employeeId" expires="180">
<p>${employee.Name}</p>
!{ShowSalesHistory(employee)}
</cache>
You have to love Spark View Engine. If you have not at least tried it out, I highly recommend downloading the Spark View Engine here.
David Hayden
Spark View Engine Tutorials