从2.2迁移到3.0后出现问题,默认情况下有效,但无法访问区域,是否有调试终端分辨率的方法? [英] Issue after migrating from 2.2 to 3.0, default works but can't access area, is there anyway to debug the endpoint resolution?

查看:194
本文介绍了从2.2迁移到3.0后出现问题,默认情况下有效,但无法访问区域,是否有调试终端分辨率的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天将asp.net core 2.2应用程序迁移到3.0,花了一点时间,但是一切都重新编译了,并且前端(默认)工作正常,但是我无法访问后端(单独的区域)。我已这样指定了端点(首先更具体地说明了迁移文档所建议的端点):

  app.UseEndpoints(endpoints => 
endpoints.MapAreaControllerRoute( areas, areas, {area:exists} / {controller = Home} / {action = Index} / {id?});
endpoints.MapControllerRoute( default, {controller = Home} / {action = Index} / {id?});
});

这是我在UseMVC中使用的确切配置,并且在2.2中禁用了端点



访问我所在地区的任何网址(我只有一个)/返回导致空白页



在调试模式下运行并连接调试器的情况下,调试输出窗口为:

  Microsoft.AspNetCore.Hosting.Diagnostics:信息:请求启动HTTP / 2.0 GET https:// localhost:44355 / Back / 
Microsoft.AspNetCore.Hosting.Diagnostics:信息:请求已在10.9489ms中完成404

我在 https://haacked.com/archive/2008/03/13/url-routing-debugger.aspx/ ,但是它可以追溯到2008年,所以我怀疑是否可以与端点路由一起使用。 / p>

我能做些什么来检查端点分辨率中发生了什么吗?



也要确认这不是视图问题,而不是当我手动转到/ back / home / index时控制器崩溃,它永远不会进入相应功能(断点设置)在第一行)

解决方案

我通过使用静态网址开头而不是我发现的{area:exists}来解决了该问题在网上的示例中,这听起来像不是干净的解决方案,但它确实解决了我的问题,因此我的解决方案是从

  app.UseEndpoints(endpoints => 
{
endpoints.MapAreaControllerRoute( areas, areas, {area:exists} / {controller = Home} / {action = Index} / {id?});
endpoints.MapControllerRoute( default, {controller = Home} / {action = Index} / {id?});
});

  app.UseEndpoints(endpoints => 
{
endpoints.MapAreaControllerRoute( Back, Back, back / {controller = Home} / {action = Index} / {id ?});
endpoints.MapControllerRoute( default, {controller = Home} / {action = Index} / {id?});
});

还要注意,是引起问题的原因还是已经存在但它破坏了身份ui路由(只有该区域具有身份验证,因此现在已按预期将我而不是空白页面重定向到/ Identity / ...,但该页面现在为空白)


I migrated an asp.net core 2.2 app to 3.0 today, took a bit but everything recompiles and the front (default) works fine, but i can't access the back (separate area). I have my endpoints specified as such (more specific first as the migration documentation recommends) :

app.UseEndpoints(endpoints =>
            endpoints.MapAreaControllerRoute("areas", "areas", "{area:exists}/{controller=Home}/{action=Index}/{id?}");
            endpoints.MapControllerRoute("default","{controller=Home}/{action=Index}/{id?}");
        });

This is the exact configuration i had with UseMVC and endpoints disabled in 2.2

Accessing any url in my area (i only have one) /Back leads to a blank page

There is absolutely nothing of value in the debug output window when running in debug mode with debugger attached :

Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request starting HTTP/2.0 GET https://localhost:44355/Back/  
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request finished in 10.9489ms 404 

I have found a debugger for routes at https://haacked.com/archive/2008/03/13/url-routing-debugger.aspx/ but it dates from 2008 so i doubt that would work with endpoint routing.

Is there anything i can do to check what's happening in the endpoint resolution?

Also just to confirm it's not a view problem not a crash in the controller when i manually go to /back/home/index it doesn't ever go in the corresponding function (breakpoint set on first line)

解决方案

I fixed it by going with a static url start instead of the {area:exists} as i found that in a sample online, this doesn'ts sound like a "clean" fix but it does fix my issue so my solution was to go from

app.UseEndpoints(endpoints =>
{
    endpoints.MapAreaControllerRoute("areas", "areas", "{area:exists}/{controller=Home}/{action=Index}/{id?}");
    endpoints.MapControllerRoute("default","{controller=Home}/{action=Index}/{id?}");
});

To

app.UseEndpoints(endpoints =>
{
    endpoints.MapAreaControllerRoute("Back", "Back", "back/{controller=Home}/{action=Index}/{id?}");
    endpoints.MapControllerRoute("default","{controller=Home}/{action=Index}/{id?}");
});

Also note sure if it caused the issue or if it was already there but it broke identity ui routing (only that area has authentication so now instead of a blank page i'm redirected to /Identity/... as expected, but that page is now blank)

这篇关于从2.2迁移到3.0后出现问题,默认情况下有效,但无法访问区域,是否有调试终端分辨率的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆