AnthonySteele / MvcRouteTester

A library for unit testing ASP MVC route tables for both Web and API Routes
Apache License 2.0
105 stars 43 forks source link

MVC 5.1 AttributeRouting with Areas always returns "...got no value for 'area' at url..." #38

Closed michaelvolz closed 10 years ago

michaelvolz commented 10 years ago

I am unsing the new MvcRouteTester for MVC 5.1.

The routetests for my top level area are working. All the routetests for any area throw the following exception:

Result Message: MvcRouteTester.Assertions.AssertionException : Expected 'MyAreaName', got no value for 'area' at url '/MyAreaname/Index'.

The controller is decorated with: [RouteArea( "MyAreaName" )]

The method is decorated with: [Route( "Index" )]

The test:

        [Fact]
        public void SimpleRouteTestExample2() {
            var routes = new RouteCollection();
            routes.MapAttributeRoutesInAssembly( typeof ( MyControllerName ).Assembly );
            routes.ShouldMap( "/MyAreaName/Index" ).To<MyControllerName>( c => c.Index() );
        }

I have no area or routeconfiguration besides AttributeRoutes.

The route itself works in the browser .

Any suggestions?

AnthonySteele commented 10 years ago

The Attribute routing is new and there are multiple issues with it! I'm stuck on a different one but I can see a few things to do on this one.

michaelvolz commented 10 years ago

It IS very new, you are right. Any solution would be a great help. I think it will be not that uncommon to have AttributeRouting and Areas at the same time.

AnthonySteele commented 10 years ago

In think that my last checkin should fix the Attribute routing area issue. It's also related to RouteCollectionRoute, so I'm hoping for a full fix to all RouteCollectionRoute-related issues soon before releasing again.

AnthonySteele commented 10 years ago

I have updated the MVC 5.1 package. This should work in the latest version as a side-effect of the main fix from Alexandr Nikitin that finds the right route for attribute routing. If not, I can pull the other fix back in.