Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在WebHost启动后修改ASP.NET核心路由映射_C#_Asp.net_Web Services_Kestrel Http Server - Fatal编程技术网

C# 如何在WebHost启动后修改ASP.NET核心路由映射

C# 如何在WebHost启动后修改ASP.NET核心路由映射,c#,asp.net,web-services,kestrel-http-server,C#,Asp.net,Web Services,Kestrel Http Server,我在ASP.NET核心应用程序中使用Kestrel运行WebHost。我使用没有MVC的简单路由模型。相关配置代码: _host = new WebHostBuilder() .UseConfiguration(_config) .UseKestrel() .ConfigureServices(services => services.AddRouting()) .Configure(app => { app.UseRouter(r =>

我在ASP.NET核心应用程序中使用Kestrel运行WebHost。我使用没有MVC的简单路由模型。相关配置代码:

_host = new WebHostBuilder()
.UseConfiguration(_config)
.UseKestrel()
.ConfigureServices(services => services.AddRouting())
.Configure(app =>
        {
            app.UseRouter(r =>
            {
                r.MapGet("some_uri_template", request_handler);

                r.MapPost("some_other_uri", other_handler);
            });
        })
        .Build();
_host.Run(_token.Token);
这个简单的服务按预期工作。但有时我需要动态修改映射的路由:删除一些路由,添加其他路由,或者在WebHost启动后更改特定路由的处理程序方法。
我该怎么做