Search code examples
c#asp.net-mvc-4asp.net-web-apistructuremapasp.net-web-api-helppages

StructureMap Exception after adding the WebApi.HelpPage to a webApi project


I followed the instructions here to add the webApi.HelpPage area and views to an existing project, which uses structureMap - but when accessing the /Help url:

StructureMap Exception Code:  202 No Default Instance defined for PluginFamily System.Web.Http.HttpRouteCollection, System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

So I'm missing something on the structureMap configure:

ObjectFactory.Configure(x => x.Scan(scan =>
            {
                scan.TheCallingAssembly();
                scan.AssembliesFromApplicationBaseDirectory();
                scan.AddAllTypesOf<IHttpModule>();
                scan.WithDefaultConventions();
            }));

Can anyone point a structureMap newbie in the right direction?


Solution

  • In structuremap 3.x I used the following in my Registry, with success:

    For<HelpController>().Use( ctx => new HelpController() );