mvc

A 3-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...


Azure Mobile Services .NET Backend Tips

I've been working with Azure Mobile Services since it was released and until recently only the JavaScript backend was available, built using node.js. Although it is very mature with many options, the community was pressuring for a .NET option and now it is available. Modeled much like a standard Web API / MVC project at first glance, there may be a few things that you like to take advantage of in these types of projects that throw you for a loop when using the new .NET option. These include Dependency Injection, Entity Framework (Migrations and Relationships), and the help page. Getting Started You have two options for getting a project started. 1. Go to the Azure Portal and create a...


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...