Creating a FubuMvc website

26 Aug 2013

  • Add new Empty Web Application to your solution
  • PM> Install-package fubumvc
  • Add folder Features
  • Add folder Features\Home
  • Add Features\Home\HomeInputModel.cs
  • Add Features\Home\HomeViewModel.cs
  • Add Features\Home\HomeEndpoint.cs
  • Add Features\Home\Home.spark
  • Setup application (ConfigureFubuMVC.cs) ```csharp Actions.FindBy(x => { x.Applies.ToThisAssembly(); x.IncludeClassesSuffixedWithEndpoint(); });

Routes.HomeIs();

Routes.ConstrainToHttpMethod(x => x.Method.Name.Equals(“Get”, StringComparison.OrdinalIgnoreCase), “GET”); Routes.IgnoreControllerNamespaceEntirely(); //removes /features/home/ from the start of urls Routes.IgnoreMethodSuffix(“Get”); //removes the trailing /get from our urls


*  HomeViewModel.cs:
```csharp
public String Message { get; set; }
  • HomeEndpoint.cs:
    public HomeViewModel Get(HomeInputModel input)
    {
      return new HomeViewModel { Message = "Dave" };
    }
    
  • Home.spark ```csharp

Hello ${Model.Message}


* Add folder Features\Test
* Add Features\Test\TestInputModel.cs
* Add Features\Test\TestViewModel.cs
* Add Features\Test\TestEndpoint.cs
* Add Features\Test\Test.spark
* TestEndpoint.cs:
```csharp
public TestViewModel Get(TestInputModel input)
{
	return new TestViewModel();
}
  • Test.spark: ```csharp

Hello ${Model.Message}


* Home.spark:
```csharp
!{this.LinkTo<TestInputModel>().Text("Test")}

c#

« Checking a Type for an Attribute Analysis of Frames in World of Warcraft »