Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller level attributes not being applied when using configuration.AddRoutesFromAssembly #277

Open
rahulbpatel opened this issue Nov 1, 2013 · 0 comments

Comments

@rahulbpatel
Copy link

When using the configuration.AddRoutesFromAssembly method it does not seem RoutePrefix or RouteArea attributes are observed. See below sample code/test:

    [RouteArea("Fakes")]
    [RoutePrefix("FakeItems")]
    public class FakeItemsController : Controller {
        [GET("Index")]
        public ActionResult Index() {
            return null;
        }
    }

    [TestClass]
    public class AttributeRoutingTests {
        [TestMethod]
        public void MapAttributeRoutes_SpecifyAssemblyInConfiguration_RoutePrefixInUrl() {
            // Arrange
            var routes = new RouteCollection();

            // Act
            routes.MapAttributeRoutes(config => {
                config.AddRoutesFromAssembly(typeof(FakeItemsController).Assembly);
            });

            // Assert  
            Console.WriteLine(String.Format("{0} routes registered.",
                routes.Count()));
            foreach (var route in routes.Cast<Route>()) {
                Console.WriteLine(route.Url);
            }
            Assert.IsTrue(routes.Any(r => ((Route)r).Url == "Fakes/FakeItems/Index"));
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant