No Description

sdbarker 1292949632 Added README.md 5 years ago
Properties c52a10ec99 initial commit 7 years ago
.gitignore b02eb16426 Update to add ControllerExtensions and refactor StringExtensions to their own class 5 years ago
ControllerExtensions.cs b02eb16426 Update to add ControllerExtensions and refactor StringExtensions to their own class 5 years ago
LICENSE 6d75a13455 update license to simplified bsd 6 years ago
README.md 1292949632 Added README.md 5 years ago
RouteCollectionExtensions.cs b02eb16426 Update to add ControllerExtensions and refactor StringExtensions to their own class 5 years ago
RouteCollectionExtensions.csproj b02eb16426 Update to add ControllerExtensions and refactor StringExtensions to their own class 5 years ago
RouteCollectionExtensions.sln b02eb16426 Update to add ControllerExtensions and refactor StringExtensions to their own class 5 years ago
StringExtensions.cs b02eb16426 Update to add ControllerExtensions and refactor StringExtensions to their own class 5 years ago

README.md

Overview

A set of extension methods for MVC3's RouteCollection that allow for strongly typed route definitions. Using this method to define your MVC3 routes will provide you compile-time errors when your controllers or actions change so you no longer have to try and debug why routes stop working.

Examples

// Map a route to the Index action on HomeController
routes.MapRoute<HomeController>(controller => controller.Index());

// Map a route to the TestPost action on HomeController which takes an instance of HomeModel
routes.MapRoute<HomeController>(controller => controller.TestPost(new Models.HomeModel()));

// Map a route to the WithParams action on HomeController which takes two paramters, id and val, with default values of 7 and foo respectively.
routes.MapRoute<HomeController>(controller => controller.WithParams(0, ""), url: "Home/WithParams/{id}/{val}", defaults: new { id = 7, val = "foo" });

// A shortcut to map the same default route that MVC3 bakes in for you
routes.MapDefaultRoute();

Parameters

action         The method that this route will call on the specified controller.
name           Optional: A string that specifies the name of the route (automatically generated as ControllerMethod if null or empty)
url            Optional: A string that specifies the URL for the route (automatically generated as Controller/Method if null or empty)
defaults       Optional: An object that contains default route values.
constraints    Optional: An object that specifies the contraints of the route.

License

Simplified BSD License:

Copyright (c) 2011-2013, Scott D. Barker (Author)

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this
  list of conditions and the following disclaimer in the documentation and/or
  other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.