ASP.NETCore6使用默认的身份验证页面而非现有的页面。
创始人
2024-09-17 15:01:11
0

可以通过下列代码示例修改ASP.NET Core 6的身份验证页面。首先,创建一个Layout视图,并在添加的视图中将身份验证服务与ASP.NET Core身份验证中间件一起配置:

Layout视图:




    
    
    @ViewData["Title"] - My Site


    
@RenderBody()

Startup.cs文件:

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext(options =>
        options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

    services.AddDefaultIdentity()
        .AddEntityFrameworkStores();

    services.AddControllersWithViews();
    services.AddRazorPages();

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

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    app.UseDeveloperExceptionPage();
    app.UseHttpsRedirection();

    app.UseRouting();

    app.UseAuthentication();
    app.UseAuthorization();

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllerRoute(
            name: "default",
            pattern: "{controller=Home}/{action=Index}/{id?}");
        endpoints.MapRazorPages();
    });
}

接下来,创建一个覆盖默认视图的视图文件,并在视图文件中自定义你的身份验证页面:

@{
    ViewData["Title"] = "登录";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@ViewData["Title"]

使用已有账户登录!


相关内容

热门资讯

一分钟快速了解!aapoker... 一分钟快速了解!aapoker透视方法,wejoker透视方法,真是是有挂(有挂教程);1、超多福利...
解密关于!wepoker有人用... 解密关于!wepoker有人用过吗,wepoker怎么开辅助,一贯存在有挂(今日头条)1、首先打开辅...
分享开挂内幕!wepoker新... 分享开挂内幕!wepoker新号好一点吗,德普之星辅助工具如何打开,一贯真的是有挂(有挂详细)1)辅...
终于知道!fishpoker透... 终于知道!fishpoker透视,德扑圈透视,竟然真的有挂(有挂功能)1、完成辅助器v3.3的残局,...
大神推荐!wepoker有没有... 大神推荐!wepoker有没有透视方法,wepoker一直输的号能继续打吗,一贯真的是有挂(有挂总结...
玩家必看科普!aapoker安... 玩家必看科普!aapoker安装包怎么使用,hhpoker软件可以玩吗,确实存在有挂(有挂攻略)1、...
我来向大家传授!德普之星透视,... 我来向大家传授!德普之星透视,wepoker钻石怎么看底牌,都是是真的有挂(有挂方法)进入游戏-大厅...
热点推荐!wepoker有没有... 热点推荐!wepoker有没有插件,hhpoker德州挂真的有吗,切实是有挂(果真有挂)运辅助工具,...
记者揭秘!拱趴大菠萝自动计算机... 记者揭秘!拱趴大菠萝自动计算机器人,哈糖大菠萝挂法,都是是真的有挂(有挂细节)所有人都在同一条线上,...
实测分享!安装不了wepoke... 实测分享!安装不了wepoker,hhpoker视频巡查真的假的,果然真的是有挂(新版有挂)1、每一...