Skip to content

Instantly share code, notes, and snippets.

@tugberkugurlu
Forked from benfoster/gist:3847790
Created October 7, 2012 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tugberkugurlu/3848310 to your computer and use it in GitHub Desktop.
Save tugberkugurlu/3848310 to your computer and use it in GitHub Desktop.
Injecting HttpRequestMessage in ASP.NET Web API
public IHttpController Create(
HttpRequestMessage request,
HttpControllerDescriptor controllerDescriptor,
Type controllerType)
{
var scope = request.GetDependencyScope() as StructureMapDependencyScope;
// Inject the current request into the underlying container
scope.Container.Inject<HttpRequestMessage>(request);
return scope.GetService(controllerType) as IHttpController;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment