[英]Change default Identity routes in an Angular & ASP.NET Core project
我將 Angular 配置為使用“登錄”路由來顯示LoginComponent
頁面。 沒關系。
但是當我嘗試在沒有登錄的情況下訪問一些授權頁面時,我在瀏覽器中得到了以下地址:
https://localhost:5001/Identity/Account/Login?ReturnUrl=%2Fapi%2FMyController%2FMyAction
這個錯誤:
默認身份 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
?
您可以嘗試在 Startup.ConfigureServices 中配置應用程序的 cookie。 調用AddIdentity
或AddDefaultIdentity
后必須調用ConfigureApplicationCookie
:
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = "/Account/Login";
});
來自 ClientApp 中的 api-authorization.module.ts 文件。 將{ path: 'login', component: LoginComponent },
添加到 RouterModule.forChild([]) 數組中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.