Why is this code commented out ?

Feb 7, 2011 at 12:41 PM


I'm trying to use the code from the trunk (Change Set 54300)

The file HttpServer.ViewEngine.Spark/SparkEngine.cs has some line commented out. Lines 200+.

Why is that?

Without these lines the Spark example does not work.

I don't understand the comment "Disabled·since·types·can·be·null."

I removed the comments for the example to work, but I guess you had a good reason to do that. Which one?

Thanks, and thumbs up for this great webserver.

Feb 7, 2011 at 12:45 PM

Because ViewData can be null and Types cannot be resolved from null variables.

What you need to do is to define the type in the top of your views: <ViewData yourVariable="typeOfVariable" />



<ViewData user="MyApp.Models.User" />

It's the standard Spark way. I'm going to support strongly typed views (using a ViewModel) in 2.0 when I release it.

Feb 7, 2011 at 12:55 PM
Edited Feb 7, 2011 at 12:56 PM

Thanks for the reply

It works fine now!


For others who may be interrested, change the file index.spark, add at the beginning:

<viewdata whom="System.String" />