【发布时间】:2020-07-02 15:13:27
【问题描述】:
我最近将我的 .Net Core 2.1 应用程序更新到 3.1,但有一部分没有按预期升级。
我编写了代码来将子域映射到 here 所述的区域
我现在意识到使用app.UseMvc() 的方法应该替换为app.UseEndpoints(),但是我在3.1 框架中找不到任何地方可以让我在app.UseEndpoints() 之前写入RouteData
//update RouteData before this
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
"admin", "{area:exists}/{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
"default", "{controller=Home}/{action=Index}/{id?}");
});
有没有办法使用中间件写信给RouteData?
我已尝试返回 app.UseMvc(),因为它仍在框架中,但 MvcRouteHandler 似乎不再存在
app.UseMvc(routes =>
{
routes.DefaultHandler = new MvcRouteHandler(); //The type of namespace could not be found
routes.MapRoute(
"admin",
"{area:exists}/{controller=Home}/{action=Index}/{id?}");
routes.MapRoute(
"default",
"{controller=Home}/{action=Index}/{id?}");
});
【问题讨论】:
标签: asp.net-core-3.1 asp.net-core-middleware