Questions tagged [asp.net-identity]

The ASP.NET Identity system is designed to replace the previous ASP.NET Membership and Simple Membership systems.

asp.net-identity
Filter by
Sorted by
Tagged with
423 votes
10 answers
196k views

ASP.NET Identity - HttpContext has no extension method for GetOwinContext

I have downloaded, and successfully ran the ASP.NET Identity sample from here: https://github.com/rustd/AspnetIdentitySample I am now in the middle of implementing the ASP.NET Identity framework in ...
Darren Wainwright's user avatar
297 votes
24 answers
438k views

How to get the current logged in user ID in ASP.NET Core?

I've done this before with MVC5 using User.Identity.GetUserId() but that doesn't seem to work here. The User.Identity doesn't have the GetUserId() method. I am using Microsoft.AspNet.Identity.
MRainzo's user avatar
  • 3,920
258 votes
11 answers
361k views

ASP.NET MVC 5 - Identity. How to get current ApplicationUser

I have an Article entity in my project which has the ApplicationUser property named Author. How can I get the full object of currently logged ApplicationUser? While creating a new article, I have to ...
Ellbar's user avatar
  • 4,024
247 votes
7 answers
106k views

Where are the Login and Register pages in an AspNet Core scaffolded app?

In VS 2017, I created a new ASP.NET Core Web Application. On the second page of the wizard, I chose Web Application, and for Authentication, I chose "Individual User Accounts". Now, I'm ...
Bob.at.Indigo.Health's user avatar
239 votes
10 answers
118k views

How can I change the table names when using ASP.NET Identity?

I am using the release version (RTM, not RC) of Visual Studio 2013 (downloaded from MSDN 2013-10-18) and therefore the latest (RTM) version of AspNet.Identity. When I create a new web project, I ...
user2315985's user avatar
  • 2,858
220 votes
4 answers
117k views

What is the claims in ASP .NET Identity

Can somebody please explain, what the claim mechanism means in new ASP.NET Identity Core? As I can see, there is an AspNetUserLogins table, which contains UserId, LoginProvider and ProviderKey. But, ...
Maxim Zhukov's user avatar
  • 10.1k
218 votes
3 answers
79k views

What is ASP.NET Identity's IUserSecurityStampStore<TUser> interface?

Looking at ASP.NET Identity (new membership implementation in ASP.NET), I came across this interface when implementing my own UserStore: //Microsoft.AspNet.Identity.Core.dll namespace Microsoft....
Brian Chavez's user avatar
  • 8,303
218 votes
4 answers
160k views

ASP.NET Identity DbContext confusion

A default MVC 5 App comes with this piece of code in IdentityModels.cs - this piece of code is for all the ASP.NET Identity operations for the default templates: public class ApplicationDbContext : ...
PussInBoots's user avatar
  • 11.5k
213 votes
6 answers
198k views

ASP.NET Identity's default Password Hasher - How does it work and is it secure?

I am wondering wether the Password Hasher that is default implemented in the UserManager that comes with MVC 5 and ASP.NET Identity Framework, is secure enough? And if so, if you could explain to me ...
André Snede's user avatar
  • 9,987
212 votes
21 answers
383k views

How to get current user in asp.net core

I want to get the current user, so I can access fields like their email address. But I can't do that in asp.net core. This is my code: HttpContext almost is null in constructor of controller. It's not ...
Mehran Hafizi's user avatar
191 votes
4 answers
153k views

Adding ASP.NET MVC5 Identity Authentication to an existing project

I have seen lots of similar pages on the web, but most of them use a new project instead of an existing one, or don't have the necessary features. So, I have an existing MVC 5 project and want to ...
Jack's user avatar
  • 1
189 votes
15 answers
106k views

Unauthorised webapi call returning login page rather than 401

How do I configure my mvc/webapi project so that a webapi method called from a razor view doesn't return the loginpage when its unauthorised? Its a MVC5 application which also has WebApi controllers ...
Tim's user avatar
  • 7,381
171 votes
9 answers
101k views

ASP.NET_SessionId + OWIN Cookies do not send to browser

I have a strange problem with using Owin cookie authentication. When I start my IIS server authentication works perfectly fine on IE/Firefox and Chrome. I started doing some testing with ...
Piotr Stulinski's user avatar
162 votes
9 answers
226k views

How to get current user, and how to use User class in MVC5?

How can I get the id of the currently logged in user in MVC 5? I tried the StackOverflow suggestions, but they seem to be not for MVC 5. Also, what is the MVC 5 best practice of assigning stuff to ...
Adam Szabo's user avatar
  • 11.4k
139 votes
6 answers
125k views

How to extend available properties of User.Identity

I'm using MVC5 Identity 2.0 for users to log into my website, where the authentication details are stored in an SQL database. Asp.net Identity has been implemented in a standard way as can be found in ...
RobHurd's user avatar
  • 2,041
137 votes
7 answers
264k views

ASP.NET Core Identity - get current user

To get the currently logged in user in MVC5, all we had to do was: using Microsoft.AspNet.Identity; [Authorize] public IHttpActionResult DoSomething() { string currentUserId = User.Identity....
jbraun's user avatar
  • 1,548
134 votes
13 answers
57k views

Configure Microsoft.AspNet.Identity to allow email address as username

I'm in the process of creating a new application and started out using EF6-rc1, Microsoft.AspNet.Identity.Core 1.0.0-rc1, Microsoft.AspNet.Identity.EntityFramework 1.0.0-rc1, Microsoft.AspNet.Identity....
LiamGu's user avatar
  • 5,337
125 votes
11 answers
164k views

ASP.NET Identity reset password

How can I get the password of a user in the new ASP.NET Identity system? Or how can I reset without knowing the current one (user forgot password)?
daniel's user avatar
  • 35k
121 votes
3 answers
106k views

The entity type 'IdentityUserLogin<string>' requires a primary key to be defined [duplicate]

i am using dotnet core 1.1 on linux, and i am having issues when i want to split up the identityContext from my regular dbContext, whenever i run the following line in my startup.cs --> configure: //....
DenLilleMand's user avatar
  • 4,134
120 votes
3 answers
51k views

What is the advantage of using async with MVC5?

What is the difference between: public ActionResult Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { IdentityResult result = IdentityManager.Authentication....
user avatar
119 votes
8 answers
169k views

Get the current user, within an ApiController action, without passing the userID as a parameter

How do we get the current user, within an secure ApiController action, without passing the userName or userId as a parameter? We assume that this is available, because we are within a secure action. ...
Shaun Luttin's user avatar
93 votes
5 answers
146k views

Get current user id in ASP.NET Identity 2.0

I just switched over to using the new 2.0 version of the Identity Framework. In 1.0 I could get a user object by using manager.FindByIdAsync(User.Identity.GetUserId()). The GetUserId() method does ...
jasonpresley's user avatar
  • 1,013
91 votes
11 answers
152k views

Creating Roles in Asp.net Identity MVC 5

There is very little documentation about using the new Asp.net Identity Security Framework. I have pieced together what I could to try and create a new Role and add a User to it. I tried the ...
colbyJax's user avatar
  • 1,053
90 votes
24 answers
60k views

How to localize ASP.NET Identity UserName and Password error messages?

Is it possible to provide localized strings for the "system" ASP.NET Identity v1 error messages, like "Name XYZ is already taken" or "User name XYZ is invalid, can only contain letters or digits"?
rootless's user avatar
  • 1,358
88 votes
9 answers
60k views

ASP.NET Identity with EF Database First MVC5

Is it possible to use the new Asp.net Identity with Database First and EDMX? Or only with code first? Here's what I did: 1) I made a new MVC5 Project and had the new Identity create the new User and ...
Patrick T's user avatar
  • 901
85 votes
4 answers
49k views

How do I define the password rules for Identity in ASP.NET 5 MVC 6 (vNext)?

The default Identity provider provided in ASP.NET 5 has very strict password rules by default, requiring a lower case character, an upper case character, a non-alphanumeric character, and a number. I ...
Ryan's user avatar
  • 3,912
85 votes
4 answers
131k views

OWIN Security - How to Implement OAuth2 Refresh Tokens

I am using the Web Api 2 template that comes with Visual Studio 2013 has some OWIN middleware to do User Authentication and the likes of. In the OAuthAuthorizationServerOptions I noticed that the ...
SimonGates's user avatar
  • 6,051
81 votes
1 answer
79k views

How to implement custom authentication in ASP.NET MVC 5

I'm developing an ASP.NET MVC 5 application. I have an existing DB, from which I created my ADO.NET Entity Data Model. I have a table in that DB which contains "username" and "password" column, and I ...
Giacomo Santarnecchi's user avatar
78 votes
12 answers
115k views

Updating user data - ASP.NET Identity

I've added custom fields to the ApplicationUser class I've also created a form through which the user can enter/edit the fields. However for some reason I'm not able to update the fields in the ...
galdin's user avatar
  • 12.9k
76 votes
6 answers
52k views

How override ASP.NET Core Identity's password policy

By default, ASP.NET Core Identity's password policy require at least one special character, one uppercase letter, one number, ... How can I change this restrictions ? There is nothing about that in ...
AdrienTorris's user avatar
  • 9,271
75 votes
1 answer
28k views

Registering Web API 2 external logins from multiple API clients with OWIN Identity

I would like the following architecture (I've made up the product name for this example): Web API 2 application running on one server http://api.prettypictures.com MVC 5 client app running on ...
joshcomley's user avatar
  • 28.5k
74 votes
1 answer
51k views

SignInManager,what it is and how,when to use?

I am exploring SignInManager class. But the information given on MSDN is very useless. It only tells what are the methods and properties provided. What I am looking for is, What is SignInManager? How ...
user786's user avatar
  • 4,124
70 votes
12 answers
93k views

How to Seed Users and Roles with Code First Migration using Identity ASP.NET Core

I have created a new clean asp.net 5 project (rc1-final). Using Identity Authentication I just have the ApplicationDbContext.cs with the following code: public class ApplicationDbContext : ...
Sauron's user avatar
  • 2,256
70 votes
3 answers
71k views

Can't get UserManager from OwinContext in apicontroller

I'm following a Microsoft sample to implement email validation with Identity 2.0.0 I'm stuck at this part public ApplicationUserManager UserManager { get { return _userManager ?? ...
Marc's user avatar
  • 16.4k
69 votes
5 answers
50k views

How to change type of id in Microsoft.AspNet.Identity.EntityFramework.IdentityUser

(ASP.NET MVC 5, EF6, VS2013) I'm trying to figure out how to change the type of the "Id" field from string to int in the type: Microsoft.AspNet.Identity.EntityFramework.IdentityUser in order to ...
BenjiFB's user avatar
  • 4,591
68 votes
5 answers
84k views

Can not instantiate proxy...Could not find a parameterless constructor

I am trying to create a unit test using Moq which tests the MongoDB.AspNet.Identity V2 provider. This line is giving me grief: var appUser = new Mock<PreRegistrationMVC.Models.ApplicationUser>(...
ChiliYago's user avatar
  • 11.8k
68 votes
5 answers
37k views

Is ASP.NET MVC 5 incompatible with the WebMatrix SimpleMembershipProvider?

We have an existing application that was build on ASP.NET MVC 4 & Web API. The admin parts of the site use Simple Membership. I'm interested in upgrading the application to MVC 5 / Web API 2, to ...
Sixten Otto's user avatar
  • 14.9k
67 votes
4 answers
109k views

How to add claims in ASP.NET Identity

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 ...
Kevin Junghans's user avatar
63 votes
5 answers
58k views

.NET Identity Email/Username change

Does anyone know how to enable a user to change username/email with ASP.NET identity with email confirmation? There's plenty of examples on how to change the password but I can't find anything on this....
devlock's user avatar
  • 979
62 votes
2 answers
42k views

How To Change Password Validation in ASP.Net MVC Identity 2?

How To Change Password Validation in ASP.Net MVC5 Identity 2 ? Thanks
Nazmul Hossain's user avatar
61 votes
3 answers
11k views

Why do the ASP.NET Identity interfaces use strings for primary and foreign keys?

I'm looking at the interfaces on the new ASP.NET Identity classes and the database it creates using Entity Framework Code First. I'm using the Visual Studio 2013 RC. At first glance the database ...
Derek Tomes's user avatar
  • 3,969
60 votes
9 answers
123k views

Redirect to login when unauthorized in ASP.NET Core

In the previous ASP.NET MVC, there was an option to redirect to the login action, if the user was not authenticated. I need the same thing with ASP.NET Core, so I: created a ASP.NET Core project ...
grokky's user avatar
  • 8,805
59 votes
5 answers
54k views

ASP.NET Identity - Multiple object sets per type are not supported

I got an error using ASP.NET Identity in my app. Multiple object sets per type are not supported. The object sets 'Identity Users' and 'Users' can both contain instances of type '...
magos's user avatar
  • 3,431
58 votes
1 answer
29k views

The AspNetUserLogins table Identity

What is the AspNetUserLogins for? Is It to store the logins from the user? How can I then update this table with that data?
Bryan's user avatar
  • 3,491
57 votes
3 answers
20k views

Asp.net Identity Validation Error

I want integrate IdentityContext with mydbcontext but i am taking this error One or more validation errors were detected during model generation: Ivdb.Dal.Concrete.EFCodeFirst.IdentityUserLogin: : ...
user1924375's user avatar
  • 10.7k
57 votes
9 answers
33k views

Merge MyDbContext with IdentityDbContext

I have a MyDbContext in a separated Data Accass Layer class library project. And I have an ASP.NET MVC 5 project with a default IdentityDbContext. The two context use the same database, and I want to ...
martonx's user avatar
  • 1,993
56 votes
14 answers
116k views

InvalidOperationException: Cannot create a DbSet for 'Role' because this type is not included in the model for the context

The following solution works in .net core 1.1, but after upgrading from 1.1 to 2.0, I received the following error: InvalidOperationException: Cannot create a DbSet for 'Role' because this type is ...
001's user avatar
  • 64k
53 votes
9 answers
71k views

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

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 ...
Mohammad Dayyan's user avatar
53 votes
2 answers
91k views

How to use JWT in MVC application for authentication and authorization?

I planned to use ASP.NET Identity 2.0 in an ASP.NET MVC application for authentication and authorization. Referring the below link JSON Web Token in ASP.NET Web API 2 using Owin I was able to ...
SDK's user avatar
  • 1,532
52 votes
10 answers
78k views

The entity type ApplicationUser is not part of the model for the current context

I'm migrating from Identity 1.0.0 to Identity 2.0.1 following this article and the migrations code generated is nothing about the new IdentityUser. It doesn't add the new columns. So I made a new ...
Marc's user avatar
  • 16.4k

1
2 3 4 5
181