Fails when password being too weak.
Hi, I am trying to get your final completed project file to work but when I try to run it I produce a 'HTTP Error 502.5 - Process Failure' page. I have also tried to follow the tutorial from the start, but this error gets produced as well at a certain point. I think it might have something to do with the SeedData but I am not sure. Any help would be fantastic because I'd love to be able to get something like this approve/reject method for a project I am working on. Thanks so much.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: b66f8ffa-699c-8b11-0cab-805f5953805f
- Version Independent ID: 7c151ed5-fd78-84fd-a08a-88912990c4ca
- Content: Create an ASP.NET Core app with user data protected by authorization
- Content Source: aspnetcore/security/authorization/secure-data.md
- Service: aspnet-core
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
I just tested the starter and it runs fine. You might try putting a breakpoint in startup.
Running the final project, i just tried the breakpoint like you said and it fails when doing the: try { SeedData.Initialize(services, testUserPw).Wait(); } Specifically, when it enters the 'await EnsureRole(serviceProvider, adminID, Constants.ContactAdministratorsRole);'
Breaking to the catch 'throw ex', right at the IR = await userManager.AddToRoleAsync(user, role); line.
Final error it produces is:
System.AggregateException HResult=0x80131500 Message=One or more errors occurred. Source=ContactManager StackTrace: at ContactManager.Program.Main(String[] args) in C:\Users\thean\Downloads\Docs-master\Docs-master\aspnetcore\security\authorization\secure-data\samples\final2\Program.cs:line 40
Inner Exception 1: ArgumentNullException: Value cannot be null.
Any further insight possibly? I hope the above erros can shed some kind of light I cannot see yet. Sorry, I am a beginner so trying my best to figure it out. Thanks so much for any help.
On Tue, May 8, 2018 at 5:43 PM, Rick Anderson [email protected] wrote:
I just tested the starter and it runs fine. You might try putting a breakpoint in startup.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aspnet/Docs/issues/6288#issuecomment-387585441, or mute the thread https://github.com/notifications/unsubscribe-auth/AjeJeZY0qgL8kTYBiIv79U8SqZxaPBGbks5twjvIgaJpZM4T3he8 .
Did you configure SeedUserPW?
~The sample needs to be updated for the much better 2.1 versions of HTTPS. To get it running for now comment out~ ~// options.Filters.Add(new RequireHttpsAttribute());~
The commenting out of that line did the trick! Thanks so much!!
On Tue, May 8, 2018 at 7:04 PM, Rick Anderson [email protected] wrote:
The sample needs to be updated for the much better 2.1 versions of HTTPS. To get it running for now comment out // options.Filters.Add(new RequireHttpsAttribute());
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aspnet/Docs/issues/6288#issuecomment-387597401, or mute the thread https://github.com/notifications/unsubscribe-auth/AjeJedp2vcMtxpmTiXGGqwNwqeteivPkks5twk6ngaJpZM4T3he8 .
You need to set up SSL in the project. Then it works with the SSL redirect. Right click on the project > properties > debug tab > enable SSL
All that HTTPS/certs works much better with ASP.NET Core 2.1
I enabled the SSL, thank you for that tip. I had seen something about enabling SSL but couldn't figure out how to access that at the time for some reason. Thanks again for all your help, it means a lot!
I added a readme.md with that info. Hopefully I can update it for the much better 2.1 bits soon,.
I'm getting this same error that AnthonySavitt described, ArgumentNullException: Value cannot be null when code IR = await userManager.AddToRoleAsync(user, role); runs. I tried configure SeedUserPW, update database and to use SSL. Also I tried to
*comment out options.Filters.Add(new RequireHttpsAttribute());
*to use app.UseMvc(); instead of app.UseMvcWithDefaultRoute();
*put some defaultConnection string to appsettings.json (don't know if I should of done that).
But this same error runs for both starter2 and for final2 program. I remember like 2 weeks ago those projects were running, but now that I installed RC 2.1, they don't want to run anymore
I am having the same issue, has anyone got any ideas how to get this running? Thanks
Had the exact same issue and I just figured it out. For me (as usual) it was something dumb and I had to add an IdentityResult to the userManager.CreateAsync(user, testUserPw) line to finally see it. Here's the whole method:
private static async Task<string> EnsureUser(IServiceProvider serviceProvider,
string testUserPw, string UserName)
{
var userManager = serviceProvider.GetService<UserManager<ApplicationUser>>();
IdentityResult IR = null;
var user = await userManager.FindByNameAsync(UserName);
if (user == null)
{
user = new ApplicationUser { UserName = UserName };
IR = await userManager.CreateAsync(user, testUserPw);
}
return user.Id;
}
My issue? The secret password I was setting for SeedUserPW didn't contain a capital letter. Ugh. Apparently that password must abide by the other password rules: capital letter, number, special character.
@iamcraigw I thought I threw an exception when it failed to create a new user - for whatever reason. PW strength too low being the most common.
ArgumentNullException: Value cannot be null.
That's a pretty big hint it didn't create the user. I'll add a code comment to that effect next update.
@iamcraigw @Rick-Anderson Thanks, it was due to the password being too weak.