My solution structure is as follows:
Areas - Games -Controllers -Views etc - Movies -Controllers - MoviesController.cs - MovieCalendarController.cs - MovieSearchController.cs -Views etc
Now I would like to do this: Go to https: // localhost / Movies / and click on the MoviesController.cs index
Go to https: // localhost / Movies / Calendar / and click the MovieCalendarController.cs index
Finally, go to https: // localhost / Movies / Search / and click on the MovieSearchController.cs index
What I tried but does not work (I get No route in the route table matches the supplied values. ) Errors:
MovieAreaRegistration.cs
public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "Movies_default", "Movies/{action}/{id}", new { controller = "Movies", action = "Index", id = UrlParameter.Optional } ); context.MapRoute( "Calendar_default", "Movies/Calendar/", new { controller = "MovieCalendar", action = "Index", id = UrlParameter.Optional } ); context.MapRoute( "Search_default", "Movies/Search/{action}/{id}", new { controller = "MovieSearch", action = "Index", id = UrlParameter.Optional } ); }
Apologies, I'm new to areas and routing
Refresh
After using attribute routing, I got into this problem:
Several types of controllers matching URLs were found. This can happen if the attribute routes on multiple controllers match the requested URL.
The following controller types were found in the request: MovieCalendar.UI.Areas.Movies.Controllers.MovieCalendarController MovieCalendar.UI.Areas.Movies.Controllers.MoviesController
Video controller
[RouteArea("Movies")] [Route("{action}")] public class MoviesController : BaseController { }
Calendar controller
[RouteArea("Movies")] [RoutePrefix("Calendar")] [Route("{action=Index}")] public class MovieCalendarController : BaseController { }
This happens when accessing the URL http: // localhost / Movies / Calendar in the hope that this will lead me to the MovieCalendarController index action method. I can understand why it complains, because there may be an ActionMethod in a MovieController called Calendar (not there).