riskfirst / riskfirst.hateoas

Powerful HATEOAS functionality for .NET web api
MIT License
78 stars 25 forks source link

RouteMap is empty #14

Closed primalfear closed 5 years ago

primalfear commented 6 years ago

When riskfirst.hateoas package is referenced by a different project in the solution and not directly referenced by the Web Project the RouteMap has no routes.

Solution Setup.

When i add the RiskFirst.Hateoas package to MySolution.WebApi the RouteMap is correctly populated. Am not logging this as a bug, it was just interesting behavior that was tricky to diagnose.

jamiecoh commented 6 years ago

Hi thanks for the report.

I'll leave this here in case it helps anyone else, plus i'll reproduce when I have a minute and see if its anything that might need fixing.

primalfear commented 6 years ago

Thanks ;)

I have experienced something similar, in the past with DotNetCore, when using reflection, and how it loads the app domain. So having not looked at the code, i would assume the controllers are being reflected to populate the RouteMap, and it's not finding the controllers...

I will also have a look at the code base a see if i can spot anything, that could remedy this behavior.

primalfear commented 6 years ago

There is another instance which is also causing the routemap to not be populated. When using DotNetCore 2.1 and the controller inherits from "Microsoft.AspNetCore.Mvc.ControllerBase" the RouteMap is Empty.

Resolution: Make sure controllers inherit from "Microsoft.AspNetCore.Mvc.Controller"

hannan-gc commented 5 years ago

Added a PR #18 for the issue mentioned by @primalfear. I had the same issue so i changed the DefaultRouteMap to look for types inheriting from ControllerBase instead.

jamiecoh commented 5 years ago

That's excellent, thanks so much for your contribution.