OWIN无法使用webapp.start隔离运行多个应用程序

And*_*dyD 5 c# asp.net asp.net-web-api attributerouting owin

当我尝试在不同的URL上启动两个应用程序时,我遇到了属性路由中间件的问题.如果我在单独的应用程序中有两个类似的路由,但使用不同的http方法web.api似乎只找到其中​​一种方法.

Microsoft.Owin.Hosting.WebApp.Start<Admin.Startup>("http://localhost:1000");
Microsoft.Owin.Hosting.WebApp.Start<Startup>("http://localhost:1001");
Run Code Online (Sandbox Code Playgroud)

如何隔离这两个应用程序,以便属性路由不冲突?

Kir*_*lla 3

根据您最后的评论,下面是过滤程序集的示例:

config.Services.Replace(typeof(IAssembliesResolver), new CustomAssembliesResolver());
Run Code Online (Sandbox Code Playgroud)
public class CustomAssembliesResolver : DefaultAssembliesResolver
{
    public override ICollection<Assembly> GetAssemblies()
    {
        ICollection<Assembly> defaultProbedAssemblies = base.GetAssemblies();

        //TODO: filter out the assemblies that you do not want to be probed

        return defaultProbedAssemblies;
    }
}
Run Code Online (Sandbox Code Playgroud)