I am following a course on ASP.Net MVC and reached a point where the course relies on the standard "Register" and "Log In" functions that Visual Studio automatically builds when you select "Individual User Accounts" when creating the proj.
Apparently, newer versions of Visual Studio now default to "No Authentication".
I've built a lot of stuff and it would be a pain to create a new project and move everything over. Is there an easier way of changing the authentication type (and generating the respective pages and controllers)?
(I don't want to add identity and tweak the authentication process manually, I want to have the same result as if I was creating a new project with "Individual User Accounts" set - with VS creating default controllers and views)
From the ASP.NET project window select "WebAPI". Click on the "Change Authentication" button. From the Change Authentication dialog select "Individual User Accounts". Click on the "OK" button.
Selecting your project and hitting F4 for the properties window allows you to change the authentication method.
Select File >> New >> select ASP.NET Core Web Application, and change the authentication to Windows Authentication. We can also configure the existing application for Windows Authentication by selecting the option of WA. To configure the authentication manually, open Visual Studio project properties >> go to Debug tab.
Add OWIN startup and authentication configuration classesIn Solution Explorer, right-click your project, select Add, and then Add New Item. In the search text box dialog, type "owin". Name the class "Startup" and select Add.
Inserted a point you missed after 6th step. Also thanks for the solution !
Found a solution!
Create a new dummy project of the same type, but with the "Individual User Accounts" authentication type selected. This will generate the files you need.
On the current project (with "No Authentication"), use the Package Manager Console to add the following references (the ones you don't have yet):
After adding these files to the solution, change their namespaces according to live project (replace all).
Open "IdentityModels.cs" and change the ConnectionString in "ApplicationDbContext" to match your live one (as in Web.config)
Open your \Views\Shared_Layout.cshtml file and add
@Html.Partial(“_LoginPartial”)
7) Copy the ... from Web.config of Dummy project to the main project.(You missed this point which might result in issues like database not being created)
All credits to https://chiroldes.wordpress.com/2015/04/02/agregando-asp-net-identity-a-un-proyecto-mvc-sin-validacion-autenticacion-o-autorizacion-de-usuarios/comment-page-1/#comment-13
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With