Click here to Skip to main content
15,891,136 members
Articles / Web Development

HelloFubuWorldSparkMVC

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
23 Jul 2011CPOL1 min read 7.1K  
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):

C#
this.Import<SparkEngine>();

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

C#
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:

C#
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.

XML
<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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer GeekSoft
Lithuania Lithuania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --