c# - Asp.net Middleware ReWrite 没有将请求转发到预期的 url
问题描述
我只是试图通过 ReWrite 中间件将所有传入请求路由到特定页面,但我没有得到想要的结果。事实上,网站的行为就好像中间件甚至不在管道中一样。我已将逻辑放在 app.UseEndpoints 之前的启动文件中。
var isMaintenance = true;
if (isMaintenance)
{
var options = new RewriteOptions()
.AddRewrite(@"^(.*)", "/maintenance", true);
app.UseRewriter(options);
}
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});
解决方案
推荐阅读
- javascript - Rails 动态 grouped_collection_select 自动改变
- linux - 如何使用tail和head在配置文件中的一行之前显示5行
- reactjs - 如何在组件标题中使用翻译?
- dji-sdk - 如何使用 DJI OSDK 让 M100 飞到所需的 GPS 位置?
- java - 如何在 Java 中将输出格式化为表格?
- python - 打印语句中的结束关键字在 Python UBUNTU 中不起作用
- jsonpath - 有没有办法从作为过滤表达式结果的 JSON 对象返回属性?
- swift - 处理由于 AlamoFire 中的异步通信导致的延迟
- r - 如何将管道和 purrr 与 {} 语法结合起来
- sql - 删除和重新创建索引