ASP.NET MVC allow very usable way of generating stongly typed URL like:
<a href="@(Url.Action<AccountSettingsController>(c => c.BusinessInfo()))">Business info</a>
or even:
<a href="@(Url.Action<SomeOtherController>(c => c.SomeActionMethod(id, paramX, paramY)))">Business info</a>
Using simple custom URL helper:
public static string Action<TController>(
this UrlHelper urlHelper,
Expression<Action<TController>> action,
string fragment = null
) where TController : BaseController
{
var routeValues = InternalExpressionHelper.GetRouteValuesFromExpression(action);
var url = UrlHelper.GenerateUrl(
routeName: null,
actionName: null,
controllerName: null,
protocol: null,
hostName: null,
fragment: fragment,
routeValues: routeValues,
routeCollection: urlHelper.RouteCollection,
requestContext: urlHelper.RequestContext,
includeImplicitMvcValues: true
);
return url;
}
It allows changing URL mapping in one place (RouteConfig) and any Controllers and Actions re-factoring doesn't mean you need to go and update each link.
I like NancyFx for it's simplicity and good IoC out of the box, but what i'm not sure why NanxyFx doesn't have support of reverse-routing (generating URL based on the action name) so it would be possible to create some static-typing helper for it.
Any ideas how to implement it in NancyFx or why if it's not possible to do, then why?