3 ms·
I started moving a large API we had built on MVC4 over to using WebAPI 2 beta and the attribute routing is amazing. Nancy looks to have similar conventions as f
by ktavera 13y ago
I started moving a large API we had built on MVC4 over to using WebAPI 2 beta and the attribute routing is amazing. Nancy looks to have similar conventions as far as routing goes but one thing I just couldn't get working properly was authentication. With WebAPI I found it more intuitive to have [SomeCustomAPIAuthenticationAttribute] on controller class and have it look for either an active session (for our browser javascript ajax calls) or if it has none then for an ApiKey (for our mobile apps) in the post data and look up to make sure the api key is valid.
Nancy is cool and i'd definitely consider using it in the future but for now, it was easier to port over our api from MVC4 to a much more familiar structure.
- philliphaydon 13y agoNancy uses extension methods in placement of Attributes. Forms auth is done by calling this.RequiresAuthentication(); you can implement an extension method to do an ApiKey check in about 5 lines of code :)
- ktavera 13y agoThanks for that! I'll have to play around with it again.