StructureMap and 5 VNext

I've created a working example of how to integrate StructureMap with 5. IoC in VNext comes out of the box but if you want to bring your own container you can.

Below you can find a full working example of how to integrate with MVC 6.

EDIT: I removed this repo, as it got stale,  proper support has been created here:

Shouldn't need to roll our own now:

MVC6 and the IHttpContextAccessor

I've been working a lot with 5 recently using the RC of visual studio 2015. There is considerable changes in both the .net framework and of course MVC.

One of the most significant changes is the dependency of 5 on the System.Web DLL. This DLL, that pretty much underpinned all that was web development, has been broken up into independent granular nuget packages that allow you to ship your application with exactly what you need.

Applications that we've used in the past have relied heavily on the HttpContext class allowing us to access the current context by the static property HttpContext.Current.

In 5 large parts of the framework are now Dependency Inject-able. In order to access the current context you can simply inject the IHttpContextAccessor into your class in order to access the current context.

The beauty of this is we can then create our mocked HttpContext using the DefaultHttpContext object that can be found in Microsoft.AspNet.Http.Core.dll

Don't forget all .net code is now open sourced and this particular interface can be found at:

The interface has also been moved to:


As of RC2 some changes have been made to the IHttpContextAccessor and it's availability. The announcement on this change can be found here: