What if I wanted to add the Individual User Accounts to an existing Web application? How do I access this screen to upgrade my project without having to recreate the project?
-
you should do it manually – Alexan Jan 4 '17 at 19:37
-
Do you have a walk thru handy on how to do it manually? Allot has changed since the latest walk thru asp.net/identity/overview/getting-started/… – Jeremiah Stillings Jan 4 '17 at 19:39
-
1Yeah i read that one already.. Step 1 says too Create an ASP.NET Core Web Application project in Visual Studio with Individual User Accounts. I am trying to add it to an existing project – Jeremiah Stillings Jan 4 '17 at 19:45
-
3some advice: create new project with authentication and then add the same nugets and code to your existing project – Alexan Jan 4 '17 at 19:51
-
1unfortunately after you created project you can't just press button for authentication. – Alexan Jan 4 '17 at 20:00
What Alex suggested worked. I did an entire blog post walk thru on how to do it as I muddled my way thru it. VS 2017- Adding Authentication: Individual User Accounts to an existing ASP.Net Core Web App
-
1I am using VS 2015 update 3 and having your issue, but your solution of course has glitches.
Package Microsoft.Extensions.CodeGenerators.Mvc 1.0.0-rc1-final is not compatible with net452 (.NETFramework,Version=v4.5.2). Package Microsoft.Extensions.CodeGenerators.Mvc 1.0.0-rc1-final supports:
– Edward Feb 13 '17 at 2:51 -
Thanks to share this information... is weird that Microsoft does not allow to access the wizard from the existing projects. – Serge Jul 27 '17 at 9:48
-
2
-
It would be helpful if this answer expounded on what was in the link (wayback?) rather than just providing a link. This is actually recommended: stackoverflow.com/help/how-to-answer – Chaim Eliyah Nov 20 '18 at 1:46
-
@ChaimEliyah I did my best to convert the WP post to this format with links to the gtihub file repo. Hope that help:) – Jeremiah Stillings Nov 20 '18 at 11:55
The accepted answer may work, but there's a much easier way... (in my case, I'm changing from Windows authentication to Anonymous authentication).
- in Solution Explorer, select your project
- press F4 key to access Project Properties (note: beware, it's not the same as right-click project --> select Properties... use the F4 key)
- set Windows Authentication to Disabled
- set Anonymous Authentication to Enabled
- in the project's Web.config, in system.web section, change [authentication mode="Windows"] to [authentication mode="None"]
- in Web.config, in system.web section, change [deny users="?"] to [allow users="*"]
(sorry for the use of brackets, instead of actual tags - HTML post restrictions prevented using tags)
So you created your first asp.net core web app and did not select authentication. Now you realize you need it.
Here is the manual way to ” Install” Individual Accounts authentication
Load your existing project solution. Right Click dependencies and hit manage NuGet Packages.
Click the BROWSE button on the top left.
Here is where you will have to manually add the dependencies that your project is missing.
The list of NuGet packages to add is long and you may have to check Include PreRelease to see them all
Microsoft.AspNetCore.Authentication.Cookies
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
Microsoft.AspNetCore.Identity.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Design
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.SqlServer.Design
Microsoft.EntityFrameworkCore.Tools
Microsoft.Extensions.Configuration.UserSecrets
Microsoft.VisualStudio.Web.CodeGeneration.Design
Next, we are going to add the missing Controller files.
Add these three files to your Controllers Folder
AccountController.cs
ManageController.cs
HomeController.cs
They are found here
Open all three of the files, and use the Find and Replace feature under edit to find Logon and type in your project name in the replace with block. MAKE sure look in ALL open documents is selected and hit Replace all.
This will code the files to your project.
This next step is to add the data that is missing.
Create a data folder and a subfolder of data called Migrations
Next, add this file to the Data folder
Now add these three files to the Migrations folder
00000000000000_CreateIdentitySchema.cs
00000000000000_CreateIdentitySchema.Designer.cs
ApplicationDbContextModelSnapshot.cs
All found here
Now close any files you have open, saving each one.
Open the four files you just added.
Use the Find and Replace feature under edit to find Logon and type in your project name in the replace with block. MAKE sure look in ALL open documents is selected and hit Replace all.
This will code the files to your project.
Our next step is to create all the missing models.
There is allot of them, So we are going to use zip and you will unzip them into your project directory
Once your project is showing the models folder open every file in the models directory and subdirectories
Use the Find and Replace feature under edit to find Logon and type in your project name in the replace with block. MAKE sure look in ALL open documents is selected and hit Replace all.
This will code the files to your project.
Our next step is to add the missing Services
There is allot of them, So we are going to use zip and you will unzip them into your project directory
Once your project is showing the services folder open every file in the services directory
Use the Find and Replace feature under edit to find Logon and type in your project name in the replace with block. MAKE sure look in ALL open documents is selected and hit Replace all.
This will code the files to your project.
Next, we are going to add the missing view files.
There is allot of them, So we are going to use zip and you will unzip them into your project directory
This WILL NOT overwrite your HOME Views
Once your project is showing the views folder open every file in the views directory
Use the Find and Replace feature under edit to find Logon and type in your project name in the replace with block. MAKE sure look in ALL open documents is selected and hit Replace all.
This will code the files to your project.
The next step is to overwrite your Startup.cs file with the updates.
This is an overwrite operation, so if you have a none default startup.cs file back it up so you can take your custom work and add it to the new file.
Once your project is showing the views folder open every file in the views directory
Use the Find and Replace feature under edit to find Logon and type in your project name in the replace with block. MAKE sure look in ALL open documents is selected and hit Replace all.
This will code the files to your project.
Now the final step is to deal with the pesky SQL database connect string in appsettings.json
Overwrite your appsettings.json file with this one
Once your project is showing the new appsetting.json file open it.
Use the Find and Replace feature under edit to find Logon and type in your project name in the replace with block. MAKE sure look in ALL open documents is selected and hit Replace all.
This will code the file to your project.
Save all files and Build it.
Troubleshooting:
If you updated any of your dependencies while in the NuGet Manager you will have to manually update your Core version by downloading the Current version HERE
If you have an orange triangle on any dependency under the NuGet packages, it just means you have to EXIT VS 17 and restart it.
I ran into both of these issues, but they are easy to overcome.
Hit your run with IIS button and enjoy seeing your new register and log on buttons on your old app.
-
7I don't have this "Debug" menu entry... which VS Version is this? – Marco Rebsamen Aug 4 '18 at 14:38