src/MVCContrib/SimplyRestful/SimplyRestfulRouteHandler.cs
/// <summary>
/// Adds the set of SimplyRestful routes to the <paramref name="routeCollection"/>.
/// </summary>
/// <param name="routeCollection">The route collection to add the  routes to.</param>
/// <param name="controllerPath">The path to the controller, you can use the special matching [controller]</param>
/// <param name="idValidationRegex">The <see cref="System.Text.RegularExpressions.Regex"/> 
/// validator to add to the Id parameter of the <see cref="Route.Values"/>, use <c>null</c> to not validate the id.</param>
/// <param name="controller">The name of the controller.  Only required if you are trying to route to a specific controller using a non-standard url.</param>
Adds the set of SimplyRestful routes to the .
Adds the set of SimplyRestful routes to the .
public static void BuildRoutes(RouteCollection routeCollection, string controllerPath, string idValidationRegex, string controller)
		{
			controllerPath = FixPath(controllerPath);
			routeCollection.Add(new Route(
				controllerPath + "/new",
				BuildDefaults(RestfulAction.New, controller),
				new MvcRouteHandler()));
			routeCollection.Add(new Route(
				controllerPath + "/{id}/{action}",
				BuildDefaults(RestfulAction.Show, controller),
				new RouteValueDictionary(new {httpMethod = new HttpMethodConstraint("GET"), id = idValidationRegex ?? MatchAny, action = "show|edit|delete"}),
				new MvcRouteHandler()));
			routeCollection.Add(new Route(
				controllerPath + "/{id}",
				BuildDefaults(RestfulAction.None, controller),
				new RouteValueDictionary(new { httpMethod = new HttpMethodConstraint("POST"), id = idValidationRegex ?? MatchAny }),
				new SimplyRestfulRouteHandler()));
			routeCollection.Add(new Route(
				controllerPath + "/{id}",
				BuildDefaults(RestfulAction.Update, controller),
				new RouteValueDictionary(new { httpMethod = new HttpMethodConstraint("PUT"), id = idValidationRegex ?? MatchAny }),
				new MvcRouteHandler()));
			routeCollection.Add(new Route(
				controllerPath + "/{id}",
				BuildDefaults(RestfulAction.Destroy, controller),
				new RouteValueDictionary(new { httpMethod = new HttpMethodConstraint("DELETE"), id = idValidationRegex ?? MatchAny }),
				new MvcRouteHandler()));
			routeCollection.Add(new Route(
				controllerPath,
				BuildDefaults(RestfulAction.Index, controller),
				new RouteValueDictionary(new { httpMethod = new HttpMethodConstraint("GET") }),
				new MvcRouteHandler()));
			routeCollection.Add(new Route(
				controllerPath,
				BuildDefaults(RestfulAction.Create, controller),
				new RouteValueDictionary(new { httpMethod = new HttpMethodConstraint("POST")}),
				new MvcRouteHandler()));
		}
public static void BuildRoutes ( RouteCollection routeCollection , string controllerPath , string idValidationRegex , string controller ) { controllerPath = FixPath ( controllerPath ) ; routeCollection . Add ( new Route ( controllerPath + " " , BuildDefaults ( RestfulAction . New , controller ) , new MvcRouteHandler ( ) ) ) ; routeCollection . Add ( new Route ( controllerPath + " " , BuildDefaults ( RestfulAction . Show , controller ) , new RouteValueDictionary ( new { httpMethod = new HttpMethodConstraint ( " " ) , id = idValidationRegex ?? MatchAny , action = " " } ) , new MvcRouteHandler ( ) ) ) ; routeCollection . Add ( new Route ( controllerPath + " " , BuildDefaults ( RestfulAction . None , controller ) , new RouteValueDictionary ( new { httpMethod = new HttpMethodConstraint ( " " ) , id = idValidationRegex ?? MatchAny } ) , new SimplyRestfulRouteHandler ( ) ) ) ; routeCollection . Add ( new Route ( controllerPath + " " , BuildDefaults ( RestfulAction . Update , controller ) , new RouteValueDictionary ( new { httpMethod = new HttpMethodConstraint ( " " ) , id = idValidationRegex ?? MatchAny } ) , new MvcRouteHandler ( ) ) ) ; routeCollection . Add ( new Route ( controllerPath + " " , BuildDefaults ( RestfulAction . Destroy , controller ) , new RouteValueDictionary ( new { httpMethod = new HttpMethodConstraint ( " " ) , id = idValidationRegex ?? MatchAny } ) , new MvcRouteHandler ( ) ) ) ; routeCollection . Add ( new Route ( controllerPath , BuildDefaults ( RestfulAction . Index , controller ) , new RouteValueDictionary ( new { httpMethod = new HttpMethodConstraint ( " " ) } ) , new MvcRouteHandler ( ) ) ) ; routeCollection . Add ( new Route ( controllerPath , BuildDefaults ( RestfulAction . Create , controller ) , new RouteValueDictionary ( new { httpMethod = new HttpMethodConstraint ( " " ) } ) , new MvcRouteHandler ( ) ) ) ; }
Adds the set of SimplyRestful routes to the .
Adds the set of SimplyRestful routes to the .
routeCollection
RouteCollection
The route collection to add the  routes to.
The route collection to add the routes to .
controllerPath
string
The path to the controller, you can use the special matching [controller]
The path to the controller you can use the special matching [ controller ]
idValidationRegex
string
The
validator to add to the Id parameter of the , use null
The validator to add to the Id parameter of the use null
controller
string
The name of the controller.  Only required if you are trying to route to a specific controller using a non-standard url.
The name of the controller . Only required if you are trying to route to a specific controller using a non - standard url .