webapi

A 2-post collection

Building Web API using MVC 6 & MongoDB

This is a quick walkthrough on using ASP.NET 5 to build a Web API layer using MongoDB. The overall concept is not too dissimilar from previous examples you may have seen using X type of database, however there are some areas covered that are either new in MVC 6 that you may find you didn't know are there. Topics Covered ConfigurationModel config.json Environment Variables OptionsModel Dependency Injection (IServiceCollection) Forcing JSON or Removing XML Formatter, Content Negotiation MongoDB Installation (OSX & Windows) mongocsharpdriver (nuget package) Testing endpoints w/ Postman or Fiddler Project Creation Depending on your environment (Windows or OS X) or preference you have a choice on how you can create the ASP.NET project. Visual Studio 2015...


Custom Routing with IRouteConstraint for ASP.NET Web API

I will admit that Regex and I do not speak anymore.  In fact, even when we did it was never a really nice conversation and sometimes ended in me cursing and/or leaving the room. If you have had this same experience when creating custom routes in ASP.NET MVC then you know what I'm talking about. IRouteConstraint IRouteConstraint has been around for some time in MVC, but it is also available in Web API too because of course it is based on the same stack for routing. Undoubtedly, the most difficult part of routes is debugging or getting the Regex right. I recently re-lived this experience when having to create a custom API route for a project something...