How to pass more than one Controller option on routes.MapRoute ()

0

I have the following route:

 routes.MapRoute(
           "Contracts",
           "Home/Contract/{contract}",
           new
           {
               controller = "Home",
               action = "Contract",
               contract = UrlParameter.Optional
           },
           new { contract = @"\w+" }
        );

Is it possible to configure this route to receive both controller Home (as already configured) and for a new controller calling Contributor ? Basically an OR within the controller parameter.

    
asked by anonymous 24.08.2017 / 20:37

1 answer

2

Just change the route declaration to:

routes.MapRoute(
       "Contracts",
       "{controller}/Contract/{contract}",
       new
       {
           controller = "Home",
           action = "Contract",
           contract = UrlParameter.Optional
       },
       new { contract = @"\w+" }
    );
    
24.08.2017 / 21:12