asp.net-identity

MVC5: UserManager.AddToRole(): “Error Adding User to Role: UserId not found”?

久未见 提交于 2019-12-18 11:04:45
问题 I have been experimenting with MVC5/EF6 and trying out the new Identity Authentication with Code-First Migrations. Everything in the solution is currently building and I can add a Migration , but when I perform an update-database through the package manager console in VS2013, my Configuration.cs file fails to fully process my test data into my Tables and outputs Error Adding User to Role: UserId not found . I have tried explicitly setting a User ID and leaving it to be generated by the

Value cannot be null. Parameter name: value, CreateIdentityAsync?

喜你入骨 提交于 2019-12-18 10:59:07
问题 I created a ViewModel( UserModel ) that implement IUser<int> (for customizing ASP.NET Identity 2.0) public class UserModel : IUser<int> { public int Id { get; set; } public string SecurityStamp { get; set; } [Display(Name = "Name")] public string FirstName { get; set; } [Display(Name = "Last Name")] public string LastName { get; set; } public string FullName { get; set; } [Display(Name = "Username")] public string UserName { get; set; } [DataType(DataType.Password)] [Display(Name = "Password"

Value cannot be null. Parameter name: value, CreateIdentityAsync?

大憨熊 提交于 2019-12-18 10:59:01
问题 I created a ViewModel( UserModel ) that implement IUser<int> (for customizing ASP.NET Identity 2.0) public class UserModel : IUser<int> { public int Id { get; set; } public string SecurityStamp { get; set; } [Display(Name = "Name")] public string FirstName { get; set; } [Display(Name = "Last Name")] public string LastName { get; set; } public string FullName { get; set; } [Display(Name = "Username")] public string UserName { get; set; } [DataType(DataType.Password)] [Display(Name = "Password"

What is the difference in the use of UserStore and UserManager in Asp.Net Identtity?

≯℡__Kan透↙ 提交于 2019-12-18 10:34:00
问题 I'm very new to Asp.Net Identity and please bear with me if this question seems silly. So, when I read the definition for UserStore class and UserManager class in Microsoft website which are in the links below, it looks like both class define operations around users (like Add, Find, Delete and Modify). So when do I use one over the other?: https://msdn.microsoft.com/en-us/library/dn315446(v=vs.108).aspx https://msdn.microsoft.com/en-us/library/dn613290(v=vs.108).aspx 回答1: Things are quite

How to store authentication bearer token in browser cookie using AngularJS

风流意气都作罢 提交于 2019-12-18 10:24:51
问题 I have created a bearer token using ASP.net Identity. In AngularJS I wrote this function to get authorized data. $scope.GetAuthorizeData = function () { $http({ method: 'GET', url: "/api/Values", headers: { 'authorization': 'bearer <myTokenId>' }, }).success(function (data) { alert("Authorized :D"); $scope.values = data; }).error(function () { alert("Failed :("); }); }; So I want to store this token into Browser cookies . If this token is present there , then take the token and get the data

AngularJS + ASP.NET Web API + ASP.NET MVC Authentication

南楼画角 提交于 2019-12-18 10:05:06
问题 I am new to AngularJS and trying to evaluate it for my new web application. Requirement: I will have one ASP.NET Web API which will be consumed from an Android, an iPhone and from a web application (ASP.NET MVC) too. ASP.NET Identity will be implemented in Web API. All three applications will call the login method of Web API to get the auth token. Problem: My problem is how to get ASP.NET MVC server side authentication work (in sync with Web API so I don't have to login for ASP.NET MVC

How does a new ASP.NET MVC 5 application know how to create a database and how does the Account Controller access the database?

爷,独闯天下 提交于 2019-12-18 10:03:28
问题 I created an ASP.NET MVC 5 Application using Visual Studio 2013 Update 2 . In the application, I have an Account controller. It's different from what I am used to and does not contain an instantiation of dbcontext . public class AccountController : Controller { private ApplicationUserManager _userManager; public AccountController() { } public AccountController(ApplicationUserManager userManager) { UserManager = userManager; } public ApplicationUserManager UserManager { get { return

MVC Bootstrap Themes

放肆的年华 提交于 2019-12-18 09:36:21
问题 I want to include theme support for the bootswatch themes in my MVC 5 app. I want the users theme to be saved and loaded when they log in. I have extended my user class to include the theme and can successfully set and save a theme on the edit user page. public class User : IdentityUser { public string BootstrapTheme {get;set;} } In the BootstrapTheme property I'll save the href attribute for the bootstrap css link. eg "~/Content/bootstrap.flatly.min.css" The plan is to set the theme in the

How to check user is in many roles in asp.net identity

梦想与她 提交于 2019-12-18 09:15:52
问题 Hi I need to check if a user is in one of the roles and i am confused with different versions of code that i found. Let me show you what i have at the moment first _manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>()); var currentUser = _manager.FindById(User.Identity.GetUserId()); if (!_manager.IsInRole(currentUser.Id, "admin")) { } And ApplicationUser public class ApplicationUser : IdentityUser { } public class ApplicationDbContext : IdentityDbContext<ApplicationUser

No owin.Environment item was found in the context - only on server

耗尽温柔 提交于 2019-12-18 09:07:22
问题 I'm getting this error: No owin.Environment item was found in the context I've seen a zillion posts telling me that I need <appSettings> <add key="owin:AppStartup" value="[AssemblyName].Startup, [AssemblyName]" /> </appSettings> but that does nothing for me. I am running Identity 2.0 and all upgraded OWIN components. Also, this runs fine locally, but when pushed to my VM, I get this error? Seems like either a setting is off or something else needs to be installed. WebPI says I have .NET 4.5.1