distup.cs文件是否需要应用程序池重新启动或回收启动。
我有一个自定义中间件,如果我们从后端禁用它,我必须像以这种方式进行配置,那么中间件应该从请求管道上脱离,如果我启用了,则我应该再次附加到请求管道,但是在此过程中,我必须重新启动或重新启动或在服务器上回收应用程序池?在下面查看示例:
class Startup{
public void Configure(IApplicationBuilder app)
{
if(isCustomMiddlewareEnable){
app.Custommiddleware()
}
}
}
I have one custom middleware which I have to configured like this way if we disable it from backend then that middleware should detach from request pipeline and if I enable then it should I again attached to request pipeline but during this process do I have to restart or recycle application pool on server? Check below example:
class Startup{
public void Configure(IApplicationBuilder app)
{
if(isCustomMiddlewareEnable){
app.Custommiddleware()
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简而言之 - 是的,因为
configure()
以及configureservices()
在应用程序启动期间一次调用一次。如果iScustommiddlewareable
更改后面的值,即您在启用文件重新加载的配置文件中更改键的值,这仍然不会影响您的应用程序行为,并将其配置为所示。您要查找的是评估的运行时,如果要满足条件,请通过中间件重定向管道。
另外,您可以随时进入中间件,但仅在满足条件时才在内部执行自定义逻辑:
In short - yes, because
Configure()
as well asConfigureServices()
are called once during application startup. If the value behindisCustomMiddlewareEnable
changes, i.e. you change a key's value in a configuration file with file reload enabled, that will still not affect your application behavior, having that configured as shown in question.What you are looking for is a runtime evaluated if statement that redirects the request pipeline through a middleware if the condition is met.
Alternatively, you can always go into the middleware, but execute your custom logic inside only if the condition is met: