0

I need to imports hundreds of users from a CSV file into the AspNetUsers table that's created for an ASP.NET MVC5 Web App.

I thought I'd write a quick console application to insert the relevant information for each user but there is one problem, the password.

This is how a user is created in ASP.NET:

var result = await UserManager.CreateAsync(user, model.Password);

but how can I do this from a Console Application? Whatever random password I'll create for each user needs to be encrypted in such a way that it can be decrypted by the ASP.NET MVC Web app.

Is there an easy way to achieve this? I started to import one class from ASP.NET MVC, and before you know it, I had to import another, and another...

So I stopped and decided to ask the question on SO as it's seems like an overkill and hopefully there is an easier way to do this.

Any suggestions would be appreciated.

Thanks.

3
  • Instead of a separate console app Create a temporary view in your MVC web app and write the logic of creating user in its controller. That way you don't need to export any classes just browse the view once Commented Jul 2, 2017 at 4:05
  • @AksheyBhat Sorry for taking so long to get back to you but been busy with other things. Anyway, if you post this as an answer, I'll award it as it worked. Thanks again. Commented Jul 14, 2017 at 1:41
  • posted my comment as answer Commented Jul 23, 2017 at 8:53

2 Answers 2

1

Instead of a separate console app Create a temporary view in your MVC web app and write the logic of creating user in its controller. That way you don't need to export any classes just browse the view once

Sign up to request clarification or add additional context in comments.

Comments

0

I would recommend writing your console application inside the same solution which contains your ASP.Net project, then add the web app as a reference in the console app. That way you can expose a function to handle adding a user inside the web app and simply call that function from within the console app.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.