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
9,004
questions
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 ...
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.
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 ...
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 ...
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 ...
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, ...
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....
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 : ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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....
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....
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)?
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:
//....
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....
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. ...
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 ...
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 ...
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"?
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 : ...
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 ?? ...
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 ...
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>(...
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 ...
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 ...
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....
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
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 ...
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 ...
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
'...
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?
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: : ...
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 ...
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 ...
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 ...
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 ...
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 ...