After Thought

More FubuMvc features

leave a comment »

In April I blogged on how to set up a simple application using FubuMvc. Today, we will look at more features that I left out in my earlier post. Thanks to Weston Binford for enumerating these changes. Please be aware that Chad Myers is planning to work on several enhancements to the FubuMvc framework including making FubuMvc controller less.

Debug: If you are wondering what is the url that invokes an action, what controllers are these actions part of, what is the method signature, what are its behaviors, how are all these wired up etc, you can find out all the details just by appending __debug to your root url. Please note that it works only on your root directory. For example url for FubuMvcSampleApplcation that is running on cassini web server is http://localhost:2052/__debug that results in the following output.


You can find more details on the Debug feature in this post that was posted on the FubuMVC Development Group.

404 or Page Not Found: To configure a 404 error page we will have to wire up the 404 behavior in our ControllerConfiguration.Configure() method.

x.ActionConventions(convention =>

Now we can add a PageNotFoundController with an Index action that takes in a PageNotFoundViewModel and returns the same model back as follows:

public class PageNotFoundController
  public PageNotFoundViewModel Index(PageNotFoundViewModel pageNotFoundViewModel)
     return new PageNotFoundViewModel
          Description = "Requested Url not found"

public class PageNotFoundViewModel : ViewModel
  public string Description { get; set; }

It is now time to add a PageNotFound View that displays the description that we populated in our controller.

<asp:Content ID="IndexUser" ContentPlaceHolderID="MainContent" runat="server">
 <%= Model.Description %>. Please check your url.

public class PageNotFoundView : FubuMvcSampleApplicationPage&amp;lt;PageNotFoundViewModel&amp;gt;

Other Url: If you want to call your action with a different url other than the standard url ({controllername}/{actioname}), you can easily override the default behavior for that action in your ControllerConfiguration.Configure() method as shown below:

x.OverrideConfigFor<UserController>(controller => controller.Index(null),
 configuration => configuration.AddOtherUrl("user/List.aspx"));

Now we can reach our Index page with an alternate url user/List.aspx. I have updated the FubuMvcSampleApplication with all the changes discussed in this post that can be downloaded here.


Written by shashankshetty

August 1, 2009 at 7:02 pm

Posted in C#, Fubu Mvc, FubuMvc, Uncategorized

Tagged with , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: