identity

Change username in MVC 5

人走茶凉 提交于 2019-12-03 07:49:38
I am using ASP.NET MVC5 and Identity 2.0 (beta). It is possible for users to change the username? I am trying using UserManager.UpdateAsync method throws an exception. Regrads, Fran. Yes it is possible using the UpdateAsync method but you need to ensure that you update both the email and username fields. var user = userManager.FindById(userId); user.Email = email; user.UserName = email; var updateResult = await userManager.UpdateAsync(user); This method works successfully for me This works for me: public async Task<ActionResult> ChangeUsername(string value) { if (UserManager.Users.Where(x => x

ASP.NET Identity

旧时模样 提交于 2019-12-03 06:57:44
问题 I'm currently building a new ASP.NET MVC 5 project which I want to release around September. I need to choose a membership system, but I'm currently quite confused about which direction should I take. The current SimpleMembership works well, but will apparently be incompatible with the upcoming ASP.NET Identity. ASP.NET Identity on the other hand is absolutely new with zero documentation and can change anytime. Finally it seems that string based IDs are used here, which seems like a very

mvc6 unauthorized results in redirect instead

白昼怎懂夜的黑 提交于 2019-12-03 06:34:50
I have been trying to prevent the redirect when I return an NotAuthorized IActionResult from a Controller, but regardless of my attempts, NotAuthorized gets translated to a Redirect. I have tried what is mentioned here (same issue, using older beta framework, I use 1.0.0-rc1-final). I do not have the Notifications namespace (has been removed in rc1-final). This is my Login Controller: [HttpPost] [AllowAnonymous] public async Task<IActionResult> Login(LoginViewModel model, string returnUrl = null) { if (ModelState.IsValid) { var result = await _signInManager.PasswordSignInAsync(model.Email,

What happen in SQL 2005 when it run out of number for an autonumber column?

淺唱寂寞╮ 提交于 2019-12-03 06:11:47
What happen when SQL Server 2005 happen to reach the maximum for an IDENTITY column? Does it start from the beginning and start refilling the gap? What is the behavior of SQL Server 2005 when it happen? You will get an overflow error when the maximum value is reached . If you use the bigint datatype with a maximum value of 9,223,372,036,854,775,807 this will most likely never be the case. The error message you will get, will look like this: Msg 220, Level 16, State 2, Line 10 Arithmetic overflow error for data type tinyint, value = 256. (Source) As far as I know MS SQL provides no

What is the recommended identity generation approach in Entity framework?

六月ゝ 毕业季﹏ 提交于 2019-12-03 06:10:51
I am interested in what is the most performant way for StoreGeneratedPattern. In past I was used to let the DB generate the ID for me but I was wondering if there is any advantage in setting StoreGeneratedPattern = None instead of StoreGeneratedPattern = Identity I am not even sure what happens when I set it to Calculated. Any recommendations? Is there any nice article related to this because msdn is not very explanatory. I am using mostly ints with few GUIDs in my schema. Ladislav Mrnka Check my blog post about StoreGeneratedPattern . It explains some differences between Identity and Computed

POCO's with the new ASP.NET Identity and MVC 5.0 + claims-based Identity

倖福魔咒の 提交于 2019-12-03 05:58:46
With the new version of VS 2013 RTM and asp.net mvc 5.0, I’ve decided to try out a few things... Needless to say, a lot has changed. For example, the new ASP.NET Identity is a replacement of the old Membership and (less old) SimpleMembership APIs. In all previous applications I’ve built, I never had the chance to work with Membership or with SimpleMembership. I’ve always ended up creating my own Login() method which would convert a submitted ViewModel to a POCO (using automapper) which in turn, would use some sort of repository to lookup the user and password. In return, I would obtain a User

Is there a way to detect circular arrays in pure PHP?

不羁岁月 提交于 2019-12-03 05:49:14
问题 I'm trying to implement my own serialization / var_dump style function in PHP. It seems impossible if there is the possibility of circular arrays (which there is). In recent PHP versions, var_dump seems to detect circular arrays: php > $a = array(); php > $a[] = &$a; php > var_dump($a); array(1) { [0]=> &array(1) { [0]=> *RECURSION* } } How would I implement my own serialization type of method in PHP that can detect similarly? I can't just keep track of which arrays I've visited, because

Is there a practical way of migrating from identity columns to hilo keys?

六月ゝ 毕业季﹏ 提交于 2019-12-03 05:07:00
问题 I work with a database that depends heavily on identity columns. However as we have now moved all applications over to NHibernate I wanted to look into using HiLo as seems to be recommended with NHibernate. Are there any strategies to do this, or any common problems to watch out for? 回答1: If this is a question about migrating an existing application to hilos which previously used auto ids, and has old data in it which needs to be migrated... then this would be my best bet (not tried it though

Full name rather than the domain id in User.Identity.Name

↘锁芯ラ 提交于 2019-12-03 04:59:42
问题 The User.Identity.Name property returns the domain login id. Which class/property exposes the actual user name? For user "John Doe" who logs into the web application supplying my_domain\jdoe **User.Identity.Name -** Returns : *my_domain\jdoe* **System.Environment.UserName** Returns: *jdoe* Which class/property returns? ... "John Doe" 回答1: If you are thinking Active Directory, you'll need to find the UserPrincipal that corresponds to the given samAccountName and get the DisplayName property

Migrating to Asp.Net Identity 2.0: new columns not being created in AspNetUsers table

为君一笑 提交于 2019-12-03 03:15:57
I get the following error when I try to register a new user, using Identity 2.0 and the default MVC 5 application: Invalid column name 'Email'. Invalid column name 'EmailConfirmed'. Invalid column name 'PhoneNumber'. Invalid column name 'PhoneNumberConfirmed'. Invalid column name 'TwoFactorEnabled'. Invalid column name 'LockoutEndDateUtc'. Invalid column name 'LockoutEnabled'. Invalid column name 'AccessFailedCount'. (repeats 2 more times, I have a total of 4 test users in AspNetUsers table.) I have a small application I've just upgraded from MVC4/Identity 1.0 to MVC5/Identity 2.0, so I had