Multiple RoutePrefixe on a controller in MVC Attribute routing?

In the new MVC Attribute Routing I know you can assign multiple Route attributes to a single ActionResult but I am looking for a way to do the same at the RoutePrefix level. I have a controller that every action in it should be accessible by 3 routes:

/Games/{Title}/Characters/{Route} /Books/{Title}/Characters/{Route} /Cinema/{Title}/Characters/{Route}

I tried putting three (3) RoutePrefix commands but get the error Deuplace RoutePrefix attribute. If I try to use a comma separated list I get Best override method for does not contain a constructor that takes 3 arguments.

Is it possible to setup a RoutePrefix so that it takes the 3 routes I want for my controller?

Answers


Running a bunch of tests I found out that I can just add 3 Route attributes to the controller level and it works the way I want.

Edit: a better way to do it I found was using the regex match method

[RoutePrefix("{Type:regex(Games|Cinema|Books)}/{SectionRoute}/Character/")]


Need Your Help

UITextView set width and height in heightForRowAtIndexPath

ios xcode uitableview interface-builder uitextview

I have a UITextView with a cell that has a UILabel and a UITextView. I am trying to set the width and height of the textview. I do this in heightForRowAtIndexPath, but my UITextView is set to aut...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.