Asp.net Identity 2.0 作弊条
Moving ASP.NET Identity model to class library
http://stackoverflow.com/questions/23446919/moving-asp-net-identity-model-to-class-library
To move the IdentityModel into a class library (which is the right thing to do according to the SRP), follow these steps:
- Create a class library. (ClassLibrary1)
- Using NuGet, add a reference to Microsoft.AspNet.Identity.EntityFramework. This will also auto-add some other references.
- Add a reference in your website to ClassLibrary1
- Find WebSite/Models/IdentityModel.cs and move it to ClassLibrary1.
Make IdentityModel.cs look like this:
public class ApplicationUser : IdentityUser
{
} public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("YourContextName")
{
}
}Make sure your website's Web.config has YourContextName pointing to the right database in the section. (Note: this database can and should house your application data).
<add name="YourContextName" connectionString="YourConnectionStringGoesHere"
providerName="System.Data.SqlClient" />Make your EF Context class inherit from your ApplicationDbContext:
public class YourContextName : ApplicationDbContext
{
public DbSet<ABizClass1> BizClass1 { get; set; }
public DbSet<ABizClass2> BizClass2 { get; set; }
// And so forth ...
}
When anyone in your site tries to log in or register, the Identity system will route them to your database with all your data which includes the Identity tables.
Use Username instead of Email for identity
In case anyone else gets here from a google search it is actually very easy to do this. If you look at the register post action it is simply setting the UserName to the Email address. So.........
Add UserName to the RegisterViewModel and add it to the register view.
<div class="form-group">
@Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.UserName, new { @class = "form-control", @placeholder = "Username or email" })
</div>
</div>
In the Register Post Action on the AccountController set the UserName to the ViewModel's UserName and the Email to the ViewModel's Email.
var user = new ApplicationUser { UserName = model.UserName, Email = model.Email };
Change AspNet Identity table names
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder); // This needs to go before the other rules! modelBuilder.Entity<ApplicationUser>().ToTable("User");
modelBuilder.Entity<IdentityRole>().ToTable("Role");
modelBuilder.Entity<IdentityUserRole>().ToTable("UserRole");
modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaim");
modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogin");
}
Make email as non unique
http://stackoverflow.com/questions/27501533/use-username-instead-of-email-for-identity-in-asp-net-mvc5
Configure below in IdentityConfig.cs
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = false
};
Change password rules
Configure in IdentityConfig.cs
PasswordValidator = new PasswordValidator
{
RequireDigit = false,
RequireLowercase = false,
RequireNonLetterOrDigit = false,
RequireUppercase = false,
RequiredLength =
};
Asp.net Identity 2.0 作弊条的更多相关文章
- asp.net identity 3.0.0 在MVC下的基本使用 序言
本人也尚在学习使用之中,错误之处请大家指正. 开发环境:vs2015 UP1 项目环境:asp.net 4.6.1 模板为:asp.net 5 模板 identity版本为:asp.n ...
- MVC使用ASP.NET Identity 2.0实现用户身份安全相关功能,比如通过短信或邮件发送安全码,账户锁定等
本文体验在MVC中使用ASP.NET Identity 2.0,体验与用户身份安全有关的功能: →install-package Microsoft.AspNet.Identity.Samples - ...
- ASP.NET Identity 3.0教程
(此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:我相信有些人和我一样,已经开始把ASP.NET 5用于产品开发了.不过现在最大的问题是 ...
- Asp.Net Identity 2.0 认证
转Asp.Net Identity 2.0 认证 一个星期前,也就是3月20日,微软发布了Asp.Net Identity 2.0 RTM.功能更加强大,也更加稳定.Identity这个东西现在版本还 ...
- 使用Asp.Net Identity 2.0 认证邮箱激活账号(附DEMO)
注:本文系作者原创,但可随意转载.若有任何疑问或错误,欢迎与原作者交流,原文地址:http://www.cnblogs.com/lyosaki88/p/aspnet-itentity-ii-email ...
- ASP.net core 2.0.0 中 asp.net identity 2.0.0 的基本使用(一)—修改数据库连接
开发环境:vs2017 版本:15.3.5 项目环境:.net framework 4.6.1 模板asp.net core 2.0 Web应用程序(模型视图控制器) 身份验证:个人用户账号 ...
- asp.net identity 3.0.0 在MVC下的基本使用(一)
注册时信箱转为用户名. 本人习惯使用用户名做注册用户,因为不管是什么终端起码都能少输入几个字符,可以提高用户体验. 这里需要更改控制器,模型和视图 1.打开Controllers目录下的Account ...
- ASP.net core 2.0.0 中 asp.net identity 2.0.0 的基本使用(四)—用户注册
修改用户注册 1.修改用户名注册规则. 打开Controllers目录下的AccountController.cs. 在控制器中找到 public async Task<IActionResul ...
- ASP.net core 2.0.0 中 asp.net identity 2.0.0 的基本使用(三)—用户账户及cookie配置
修改用户账户及cookie配置 一.修改密码强度和用户邮箱验证规则: 打开Startup.cs,找到public void ConfigureServices(IServiceCollection s ...
随机推荐
- 2、Oracle Logminer性能测试
Oracle Logminer性能测试 1 测试介绍 1.1 测试目的 通过模拟不同环境下LogMiner解析联机/归档日志文件运行情况,通过测试所获取的数据分析,通过对以下两点的验证来确定通过Log ...
- Storm集群部署
一. 说明 Storm是一个分布式实时计算系统,Storm对于实时计算的意义就相当于Hadoop对于批量计算的意义.对于实时性较高的系统Storm是不错的选择.Hadoop提供了map, reduce ...
- win8.1安装开发工具vs2013.3+mssql2012全程
几个常用的命令 重起计算机命令:shoutdown.exe -r -t 0 立刻重起 在远程桌面中没有关机重起的选项,这个命令是必须的 远程桌面连接:mstsc 硬件环境:I7 4770 64RAM ...
- background的属性和背景图片定位的实例
本文内容: 1.背景图片定位示例 2.background常用的属性值 3.background-repeat新增的round.space属性 4.background-size的属性值(着重介绍co ...
- [爬虫学习笔记]Url过滤模块UrlFilter
Url Filter则是对提取出来的URL再进行一次筛选.不同的应用筛选的标准是不一样的,比如对于baidu/google的搜索,一般不进行筛选,但是对于垂直搜索或者定向抓取的应用,那 ...
- WPF关闭应用程序方法
很多人认为关闭应用程序应该很简单,例如WindowsForm里一个Application.Exit();方法就可以解决问题,但在WPF里面可别滥用,因为WPF里Application类没有该方法,倒是 ...
- .net多线程的发展
APM和EAP是在async/await之前的两种不同的异步编程模式. APM如果不阻塞主线程,那么完成通知(回调)就会执行在另外一个线程中,从而给我们更新UI带来一定的问题. EAP的通知事件是在主 ...
- [转]微信公众平台WeChat PHP SDK
地址:https://github.com/dodgepudding/wechat-php-sdk 微信公众平台php开发包,细化各项接口操作,支持链式调用 微信支付接入文档: https://mp. ...
- Python基础(二),Day2
常用的数据类型 int 整型 float 浮点 bool 布尔 string 字符串 列表的语法和用法 # 创建一个列表 list = [] #一个空列表 list = ['2323123','asd ...
- Android 手机卫士18--流量统计
//获取手机下载流量 //获取流量(R 手机(2G,3G,4G)下载流量) long mobileRxBytes = TrafficStats.getMobileRxBytes(); //获取手机的总 ...