How to restrict Asp.net Web API / Owin discovery of controllers by namespace?
<p>In the same project, I have two similar startup classes like this :</p>

<pre><code>namespace X.A
{
    public class AStartup
    {
        public void Configuration(IAppBuilder appBuilder)
        {
            HttpConfiguration config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();
            config.EnsureInitialized();

            appBuilder.UseWebApi(config);
        }
    }
}
</code></pre>

<p>and </p>

<pre><code>namespace X.B
{
    public class BStartup
    {
        public void Configuration(IAppBuilder appBuilder)
        {
            HttpConfiguration config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();
            config.EnsureInitialized();

            appBuilder.UseWebApi(config);
        }
    }
}
</code></pre>

<p>I also have several controllers, some are in namespace X.A... : </p>

<pre><code>namespace X.A.SomePlace
{
    [RoutePrefix("A/SomeRouting")]
    public class Controller1 : ApiController
    {
        [Route("SomeMethod")]
        [HttpPost]
        [ResponseType(typeof(SomeMethodResponse))]
        public IHttpActionResult GetParameters([FromBody] SomeMethodRequest request)
        {
            // Some code
        }
    }
}
</code></pre>

<p>... and others are in namespace X.B...:</p>

<pre><code>namespace X.B.SomeOtherPlace
{
    [RoutePrefix("B/AnotherRouting")]
    public class Controller2 : ApiController
    {
        [Route("AnotherMethod")]
        [HttpPost]
        [ResponseType(typeof(AnotherMethodResponse))]
        public IHttpActionResult AnotherMethod([FromBody] AnotherMethodRequest request)
        {
            // Another code
        }
    }
}
</code></pre>

<p>...and all controllers are in the same Asssembly.</p>

<p>Currently, all controllers get automagically registered to both API.
I would like to restrict the controller discovery by namespace (i.e. AStartup registers all controllers from X.A.... and BStartup registers all controllers from X.B...)</p>

<p>Is there a way to do this with MapHttpAttributeRoutes?</p>

<p>I would be also happy with another method that does not use attribute routes (i.e. if you have a method where I have to explicitely registers each controller programatically, that would work fine for me).</p>