Fubumvc not only allows you to define your own conventions, i.e. the ways in which your code gets wired up into your web app, it comes with its own set of conventions. Before you start re-inventing some wheels, check out what the framework has up its sleeve.
When you like checking out the source code, the bootstrapping of in-built conventions is found in the FubuRegistry.
Without further ado, let us list it:
- If you mark an action with the HtmlEndpointAttribute, the model returned will be rendered as HTML by calling ToString() on the model.
- If you return a string from an action and the action’s method name end on Html, it will be used as the response assuming it is HTML.
- If you return a string without having the action name end on HTML, it will be rendered out with MIME-type text/plain.
- When your output model implements the interface JsonMessage, it will be rendered out as Json.
- When you like using the API from the HtmlTags library, you can output either a HtmlDocument or HtmlTag from your action and it will be output as HTML.
- When your action outputs a value from the System.Net.HttpStatusCode, Fubumvc ensures that the code is used as response status code.
- Your actions can cause a redirect / transfer to a different Url/Action. This happens either by returning a FubuContinuation or a model implementing IRedirectable.
- If your output model implements IHaveHeaders, you can provide a collection of header values which will be added as HTTP Header to the response.
There are a couple of other conventions in a number of areas, however, I haven’t followed the underlying code enough to be able to write down a summary. Even so, I hope that knowledge about the conventions above helps you in writing less code.