我已经用一些更相关的信息编辑了我的问题。
我有一个托管在IIS
上的Owin Web-Api
网站。
该应用程序具有具有 2 个操作的单个控制器。
该应用程序运行良好。所有操作都返回有效结果。
回收应用程序池后,应用开始返回 404。只有重建 bin 目录(我目前正在本地工作(才能恢复应用程序(在应用程序池上停止\启动不会做任何积极的事情(。
这是我的创业.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
我发现了问题。
我的启动类位于外部 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 类时,一切正常。
因此,现在,我已经在应用程序的 dll 上创建了一个虚拟适配器,并分配了指向它的owin:appStartup
。
我不确定这是否是设计使然。