asp.net-identity

How to obtain a list of Users from ASP.NET Identity?

南楼画角 提交于 2019-12-28 08:07:21
问题 Edit: This question is outdated The Identity Framework was a moving target at the moment I asked this. The authors changed quite a few things and they have decoupled several others, making everything easier. Have a look at the Asp.NET Identity Sample project on github. I'm creating a small application that requires user management. Registration is not allowed, instead there is a super user that will create and modify login information. I'm using the new ASP.NET Identity membership system, and

ASP.NET identity use email instead of user name [duplicate]

感情迁移 提交于 2019-12-28 06:18:19
问题 This question already has answers here : ASP.Net UserName to Email (7 answers) Closed 3 years ago . How can I use email instead of user name in the new ASP.NET identity system? I tried to change the RegisterViewModel class: [Display(Name = "Email address")] [Required(ErrorMessage = "The email address is required")] [EmailAddress(ErrorMessage = "Invalid Email Address")] public string UserName { get; set; } but when I enter an mail adress I am getting the error: User name fsdfsd@fsdfsd.de is

MVC 5 Owin Facebook Auth results in Null Reference Exception

为君一笑 提交于 2019-12-28 02:51:08
问题 I'm trying to setup integrated OWIN Facebook authentication in a new MVC 5 project in Visual Studio 2013. I have configured apps and keys as per this tutorial: http://www.asp.net/mvc/tutorials/mvc-5/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on However, I'm getting a NullReferenceException thrown from this call in the AccountController: [AllowAnonymous] public async Task<ActionResult> ExternalLoginCallback(string returnUrl) { var loginInfo = await

How to add claims in ASP.NET Identity

本小妞迷上赌 提交于 2019-12-27 11:57:48
问题 I am trying to find a document or example of how you would add custom claims to the user identity in MVC 5 using ASP.NET Identity. The example should show where to insert the claims in the OWIN security pipeline and how to persist them in a cookie using forms authentication. 回答1: Perhaps the following article can help: var claims = new List<Claim>(); claims.Add(new Claim(ClaimTypes.Name, "Brock")); claims.Add(new Claim(ClaimTypes.Email, "brockallen@gmail.com")); var id = new ClaimsIdentity

Is this approach correct in MVC-5?

送分小仙女□ 提交于 2019-12-25 18:08:25
问题 Please check my previous question Here. As i mentioned in my previous question that i am using Asp.Net Identity for user authentication. According to the answer provided in the previous question i did this: public class Student: IdentityUser { ... ..... *other properties* public int ContactId { get; set; } public virtual Contact Contact { get; set; } } public class Teacher: IdentityUser { ... ..... *other properties* public int ContactId { get; set; } public virtual Contact Contact { get; set

In MVC5 how can I create user records in code?

╄→гoц情女王★ 提交于 2019-12-25 15:55:38
问题 VS2013, MVC5, VB The MVC5 template works well to create new users from the Register View while the application is running. But if I want to create users in code, how do I do that? The following is naïve code, but demonstrates what doesn't work: Dim user = New ApplicationUser() With {.UserName = "name@live.com", .Email = "name@live.com"} Dim acct As New AccountController acct.UserManager.CreateAsync(user, "Temp1.11") This doesn't work because there is no HttpContext for UserManager. There's a

Folder authorization in asp.net Identity 2.1

陌路散爱 提交于 2019-12-25 12:04:09
问题 I searched but couldn't find role based authorization for access to folders or files in .net identity 2.1 as there is in form based authorization <location path="Pictures"> <system.web> <authorization> <allow roles="Administrators"/> //Allows users in Admin role <deny users="*"/> // deny everyone else </authorization> </system.web> </location> Is there any way to implement this in .net identity? 回答1: You can write a filter: public class FilterStaticFilesAttribute :

Folder authorization in asp.net Identity 2.1

六眼飞鱼酱① 提交于 2019-12-25 12:03:54
问题 I searched but couldn't find role based authorization for access to folders or files in .net identity 2.1 as there is in form based authorization <location path="Pictures"> <system.web> <authorization> <allow roles="Administrators"/> //Allows users in Admin role <deny users="*"/> // deny everyone else </authorization> </system.web> </location> Is there any way to implement this in .net identity? 回答1: You can write a filter: public class FilterStaticFilesAttribute :

EntityFramwork Power Tools error while generating views

冷暖自知 提交于 2019-12-25 10:01:57
问题 When trying to use the Generate Views function of EntityFramework Power Tools (0.9 beta), the generation fails and I get the following error at the Output window: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not load type 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. at MyProject

Multiple users same browser asp identity

流过昼夜 提交于 2019-12-25 09:57:51
问题 We have an application which has two user types. One of them is an administrator and the other one is a client. We are using AspNet identity to authenticate the user and issue a cookie. However, there is a scenario where the administrator and the user share the same browser. When the client logs in, the cookie gets overridden and when coming back to the administrator pages we lose authentication. The same happens the other way around (client is logged in first, then admin). Is there a way to