尽管在匹配程序集名称和全局程序集名称中具有Startup.cs,但不会自动检测OWIN启动类

时间:2017-10-30 17:29:25

标签: asp.net-web-api

我创建了一个web API并将OWIN中间件添加到项目中,即Startup.cs,Startup.Auth.cs和OpenIdConnectCachingSecurityTokenProvider.cs(根据Azure AD B2C的需要)。

但是,我的Web API要求我在Startup.cs中使用程序集属性[assembly: OwinStartup(typeof(My_Web_API_2.Startup))],否则不会检测到OWIN启动类。 TaskService app in the Azure AD B2C sample不需要该属性。

OWIN Startup class detection docs状态

  

命名约定:Katana在中查找名为Startup的类   与程序集名称或全局名称空间匹配的名称空间。

但是我的Web API使用匹配的程序集名称和全局命名空间?我的Web API中缺少什么来检测OWIN Startup类?

1 个答案:

答案 0 :(得分:0)

程序集名称包含-,但名称空间有_个。

assembly and namespace names

这可能发生在您执行File -> New Project时。 VS将连字符转换为命名空间中的下划线(并没有告诉你!)。