OWIN Web Api - 对最近 returned 200 的请求突然响应 return 404

OWIN Web Api - responses suddenly return 404 on requests that recently returned 200

我用一些更相关的信息编辑了我的问题。

我有一个托管在 IIS 上的 Owin Web-Api 网站。

该应用程序有一个带有 2 个操作的控制器。
该应用程序运行良好。所有操作 return 有效结果。

当应用程序池被回收时,应用程序开始 returning 404。 只有重建 bin 目录(我目前在本地工作)才能恢复应用程序(应用程序池上的 stop\start 没有任何积极作用)。

这是我的 Startup.cs 的样子:

var httpConfiguration = new HttpConfiguration();
WebApiConfiguration.Register(httpConfiguration); // will show it's content later

appBuilder.UseRequestScopeContext(); // Third party OwinRequestScopeContext
appBuilder.Use<IOCContainerMiddleware>(); // Custom middleware that creates an IOC container per request and disposes it at the end of the request

appBuilder.UseWebApi(httpConfiguration);

WebApiConfiguration.Register:

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{action}",
constraints: new { httpMethod = new HttpMethodConstraint(HttpMethod.Post) },
defaults: null);

ConfigureDependencyResolver(config); // Custom dependency resolver that uses the IOC container from above

我发现了问题。

我的启动 class 位于一个外部 dll 上,该 dll 引用了我的应用程序(并存在于我的 bin 文件夹中)。

我在 web.config:

appSettings 部分添加了 "owin:appStartup"
<appSettings>
    <add key="owin:appStartup" value="WebApiServicePrototype.Startup.ServiceStartup, WebApiServicePrototype" />
</appSettings>

owin:appStartup 键指向外部 dll 时它起作用,直到应用程序的应用程序池被回收(我在 IIS 上托管),然后开始抛出 404 结果。

owin:appStartup 指向当前应用程序 dll 中存在的 Startup class 时,一切正常。

所以现在,我在应用程序的 dll 上创建了一个虚拟适配器,并分配 owin:appStartup 指向它。

我不确定这是否是设计使然。