Change routing in ASP.NET Core Identity UI?
JavIEr recommends one of the following options when wanting to
Use the scaffolding element of the Default UI and make all necessary customisations yourself. Use a redirection rule that points the old routes to the new routes. Don’t use the Default UI at all.
customise the URLs:
从新的ASP.NET Core 2.1 MVC项目,使用身份验证:个人用户帐户设置,您如何不使用默认UI?它似乎默认安装了IDentity Core.
创建项目后,删除默认UI剃刀页面的方法是什么,仍然使用IDentity Core?
我可以删除/ IDentity /区域,然后创建自己的AccountController吗?
解决方法 使用 the article linked by Panagiotis Kanavos,我能够找到解决方案.在ASP.NET Core 2.1.0-prevIEw1中,有一行.AddDefaultUI(),您不必将其包含在Startup.cs中.
services.AddIDentity<IDentityUser,IDentityRole>(options => options.Stores.MaxLengthForKeys = 128) .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultUI() .AddDefaultTokenProvIDers();
然而,在Core 2.1的最终版本中,相同的部分被简化为:
services.AddDefaultIDentity<IDentityUser>() .AddEntityFrameworkStores<ApplicationDbContext>();
解决方案是,如果将AddDefaultIDentity更改回AddIDentity,则可以覆盖默认值. I.E.不包括.AddDefaultUI()(也不包括UI),你可以编写自己的.
services.AddIDentity<IDentityUser,IDentityRole>(options => options.Stores.MaxLengthForKeys = 128) .AddEntityFrameworkStores<ApplicationDbContext>() // .AddDefaultUI() .AddDefaultTokenProvIDers();
然后,我认为删除/ Areas / IDentity /文件夹是安全的,但我不是100%
更新:
我清理了我的答案,详细说明了我最终使用的最终解决方案,删除了ASP.NET Core 2.1附带的默认身份UI剃刀页面,并使用MVC代替.
1)在Startup.cs中,
public voID ConfigureServices(IServiceCollection services) { // Unrelated stuff commented out... // BEGIN: IDentity Setup (OverrIDes default IDentity) services.AddIDentity<ApplicationUser,IDentityRole>(options => options.Stores.MaxLengthForKeys = 128) .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProvIDers(); // END: IDentity Setup services.Configure<IDentityOptions>(options => { // Set your IDentity Settings here (password length,etc.) }); // More unrelated stuff commented out... services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // Added after AddMvc() services.ConfigureApplicationcookie(options => { options.LoginPath = $"/account/login"; options.logoutPath = $"/account/logout"; options.AccessDenIEdpath = $"/account/access-denIEd"; }); // More unrelated stuff commented out... }
显然,如果需要,将ApplicationUser和IDentityRole替换为您自己的类.
2)删除ASP.NET Core 2.1项目默认使用的IDentity文件夹.
3)创建一个新的单独的ASP.NET Core 2.0项目(不是“2.1”),在项目创建窗口中选择单个用户帐户身份验证.
4)将AccountController和ManageController以及相应的viewmodel和VIEws从2.0项目复制到ASP.NET Core 2.1项目.
做到这一点,我到目前为止还没有遇到任何问题.
总结以上是内存溢出为你收集整理的ASP.NET Core 2.1身份:如何删除默认UI剃刀页面?全部内容,希望文章能够帮你解决ASP.NET Core 2.1身份:如何删除默认UI剃刀页面?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)