【问题标题】:Change default Identity routes in an Angular & ASP.NET Core project更改 Angular 和 ASP.NET Core 项目中的默认身份路由
【发布时间】:2020-08-04 16:55:08
【问题描述】:

我将 Angular 配置为使用“登录”路由来显示 LoginComponent 页面。没关系。

但是当我尝试访问一些没有登录的授权页面时,我在浏览器中得到了以下地址:

https://localhost:5001/Identity/Account/Login?ReturnUrl=%2Fapi%2FMyController%2FMyAction

这个错误:

默认的 Identity UI 布局需要通常位于“/Pages/_LoginPartial”或“/Views/Shared/_LoginPartial”的局部视图“_LoginPartial”才能工作。根据您的配置,我们在以下位置查看了它:
/Areas/Identity/Pages/Account/_LoginPartial.cshtml
/Areas/Identity/Pages/_LoginPartial.cshtml
/Areas/Identity/Pages/Shared/_LoginPartial.cshtml
/Areas/Identity/Views/Shared/_LoginPartial.cshtml
/Pages/Shared/_LoginPartial.cshtml
/Views/Shared/_LoginPartial.cshtml

是否可以指向 /login 页面而不是 /Identity/Account/Login

【问题讨论】:

    标签: c# asp.net-core


    【解决方案1】:

    您可以尝试在 Startup.ConfigureServices 中配置应用的 cookie。 ConfigureApplicationCookie必须在调用AddIdentityAddDefaultIdentity后调用:

    services.ConfigureApplicationCookie(options =>
    {               
          options.LoginPath = "/Account/Login";             
    });
    

    【讨论】:

      猜你喜欢
      • 2019-06-09
      • 2020-03-23
      • 2018-11-14
      • 1970-01-01
      • 2020-05-31
      • 2017-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多