亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 ASP.NET Core Identity UI 中登錄鏈接不起作用

在 ASP.NET Core Identity UI 中登錄鏈接不起作用

C#
滄海一幻覺 2022-12-31 13:24:29
我已將我的 asp.net core 2.2 應用程序配置為基于ASP.NET Core 項目中的此腳手架標識(因此我可以自定義其外觀)腳手架標識=>創建完整標識 UI 源鏈接。http : //localhost:12345/identity/account/login url 在我直接在瀏覽器中請求時有效,但在我將其作為主頁上的鏈接時無效。我究竟做錯了什么?啟動.cs:public void ConfigureServices(IServiceCollection services)        {            services.Configure<CookiePolicyOptions>(options =>            {                // This lambda determines whether user consent for non-essential cookies is needed for a given request.                options.CheckConsentNeeded = context => true;                options.MinimumSameSitePolicy = SameSiteMode.None;            });            services.AddDbContext<ApplicationDbContext>(options =>                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));            services.AddIdentity<IdentityUser, IdentityRole>()                //.AddDefaultUI(UIFramework.Bootstrap4)                .AddEntityFrameworkStores<ApplicationDbContext>();            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2).                AddRazorPagesOptions(options =>            {                options.AllowAreas = true;                options.Conventions.AuthorizeAreaFolder("Identity", "/Account/Manage");                options.Conventions.AuthorizeAreaPage("Identity", "/Account/Logout");            });            services.ConfigureApplicationCookie(options =>            {                options.LoginPath = $"/Identity/Account/Login";                options.LogoutPath = $"/Identity/Account/Logout";                options.AccessDeniedPath = $"/Identity/Account/AccessDenied";            });            services.AddSingleton<IEmailSender, EmailSender>();        }
查看完整描述

1 回答

?
鴻蒙傳說

TA貢獻1865條經驗 獲得超7個贊

有兩種方法可以做到這一點。


方法 1:使用href


<a href="/identity/account/login" 

    class="btn btn-sm btn-white btn-icon rounded-pill d-none d-lg-inline-flex"

    data-toggle="tooltip" data-placement="left">

    <span class="btn-inner--icon"><i class="fas fa-sign-in"></i></span>

    <span class="btn-inner--text">Login</span>

</a>

方法二:


<a asp-area="Identity"  asp-page="/Account/Login" 

    class="btn btn-sm btn-white btn-icon rounded-pill d-none d-lg-inline-flex"

    data-toggle="tooltip" data-placement="left">

    <span class="btn-inner--icon"><i class="fas fa-sign-in"></i></span>

    <span class="btn-inner--text">Login</span>

</a>


查看完整回答
反對 回復 2022-12-31
  • 1 回答
  • 0 關注
  • 94 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號