Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

HelloFubuWorldSparkMVC

0.00/5 (No votes)
23 Jul 2011 1  
HelloFubuWorldSparkMVC

Rumours say the WebForms support in FubuMVC is soon to be abandoned, so let's not stick to the outdated technology and move on. Recently, the Spark integration has been reworked, and the necessary bits added to the official NuGet source, so using Spark in Fubu became so ridiculously simple that you don't have to even know how to pronounce "git" in order to handle it.

Setup

Add the FubuMVC.Spark NuGet package to your project. Then add one of these lines of code to your registry setup (the ConfigureFubuMVC constructor created for us by the NuGet installer). The first version is mainstream, and will be used for all View engines (including WebForms):

this.Import<SparkEngine>();

The other one is Spark-specific, and lets you add some engine configuration (which we won't dive into here):

this.UseSpark();

That's it! You can see the whole registry here.

See It In Action

We'll use a simple controller from the previous post:

namespace FubuDemo.Greetings {
	public class SayController {
		public HelloModel Hi() {
			return new HelloModel {Name = "John Doe"};
		}
	}
}

We'll create a simple Spark view without a master. Note that we have to declare the full model type (without the assembly name). We'll put the view in the same folder as the controller.

<viewdata model="FubuDemo.Greetings.HelloModel" />
<use master=""/>
<html>
  <body>
	Hi ${Model.Name}!
  </body>
</html>

Navigating to the website root will bring us to the page that says "Hi John Doe!"

Setting Up An OSS Project Can't Be So Simple, Where's the Catch?

No catch, silly. Simpler than drag'n'drop. Try it, it's fun!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here