Today is a preview release of the AppAir.Web utility library for ASP.NET MVC.
What is included is StrongRoutes and two helper functions to clean up your views. The general idea is you have static classes for routes so they can be referenced anywhere in your Controllers and Views without using nasty Magic Strings.
If you like what you see or have some suggestions give me a shoutout via here or tweeter @bleevo.
All code is licensed as MIT
Source Code: http://github.com/bleevo/AppAir.Web/tree/master
Direct Download: http://github.com/bleevo/AppAir.Web/zipball/master
View
<%=Html.LinkTo("Register", UserRoutes.Register)%> <a href="<%=Url.LinkTo(UserRoutes.Register)%>">Register</a>
Global.asax
public class MvcApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); AppAir.Web.Routing.StrongRouteRegistrar.MapFrom(typeof(UserRoutes), routes); } protected void Application_Start() { RegisterRoutes(RouteTable.Routes); } } public static class UserRoutes { [RouteOrder(2)] public static readonly StrongRoute Register = StrongRoute.Map<UserController>("register", c => c.Register()); [RouteOrder(1)] public static readonly StrongRoute Logout = StrongRoute.Map<UserController>("logout", c => c.Logout()); public static readonly StrongRoute Login = StrongRoute.Map<UserController>("login", c => c.Login()); }
0 Responses to “ASP.NET MVC StrongRoutes AppAir.Web Preview Release”