Gau*_*san 7 c#-3.0 typescript2.0 asp.net-core-2.0 angular
第一个请求要花时间才能达到服务器API方法,因为它会在启动任务中预先构建服务,有人可以建议我减少在IIS中发布后第一个请求的初始延迟。
// This method gets called by the runtime.
// Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IContactService, ContactService>();
services.AddTransient<IPersonService, PersonService>();
services.AddTransient<IDashboardService, DashboardService>();
services.AddTransient<IEmployeeService, EmployeeService>();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/build";
});
}
Run Code Online (Sandbox Code Playgroud)
需要注入100多个服务,这需要花费一些时间进行预建。
这可能是您的 IIS 配置存在问题,因为应用程序池是从不活动状态回收的。
如果您在“高级设置”下设置了应用程序池的启动模式,那么无论您何时调用它,它都应该可以使用,除非您恰好在回收发生时调用它。
这可以通过以下方式找到:
对于后一期的回收,只要需要(每 29 小时)一次,您可以安排回收在设定的时间进行,以免造成干扰。在同一高级设置屏幕上:
Change Regular Time Interval (minutes)至 0Specific Times并单击...显示 TimeSpan[] Array 的位置。