Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application not auto creating AccountController

I am creating an MVC project in VS2017 and in VS2015, when you create an MVC templated ASP.NET Web App, it will automatically build an account controller for you which adds register and log in functionality. It will add an AccountController.cs and ManageController.cs to controllers with the appropriate views.

But in VS2017, when I create an MVC project it doesn't add this to the project. I've tried importing the files from an old VS2015 project, but It didn't seem to work. How can I get around this? Is there a way to create a project with the account controller or did they remove that in VS2017?

like image 685
MJohnston Avatar asked Apr 22 '17 19:04

MJohnston


People also ask

How to create Controller in vs?

The easiest way to create a new controller is to right-click the Controllers folder in the Visual Studio Solution Explorer window and select the Add, Controller menu option (see Figure 1). Selecting this menu option opens the Add Controller dialog (see Figure 2).

How to create Controller in ASP net?

Select the EXPLORER icon and then control-click (right-click) Controllers > New File and name the new file HelloWorldController. cs . In Solution Explorer, right-click Controllers > Add > New File. Select ASP.NET Core and Controller Class.

Can we run MVC in Visual Studio code?

Visual Studio Code (VS Code) allows you to create ASP.NET MVC application on Windows and Mac systems. To use C1 MVC controls, few additional steps are required to configure the project created using the Visual Studio Code IDE. Create a new folder on your system for the ASP.NET Core MVC application.


4 Answers

You need to select some form of authentication when you create the app.

enter image description here

like image 131
Maria Ines Parnisari Avatar answered Oct 24 '22 17:10

Maria Ines Parnisari


You can easily execute this command in the nuget console and your problem will be solved:

Install-Package Microsoft.AspNet.Identity.Samples -Version 2.2.0-alpha1
like image 37
Mohammad Shobeyri Avatar answered Oct 24 '22 16:10

Mohammad Shobeyri


My issue/resolution was slightly different than the accepted answer. I was choosing the "Web API" template while checking the "MVC" checkbox and I DID select Individual User Accounts, but the account controller/views were still not created. It appears the Account boilerplate doesn't get generated with the Web API option, regardless of what you choose for Authentication.

like image 1
Ageonix Avatar answered Oct 24 '22 16:10

Ageonix


Had this problem myself today creating an ASP.NET Core Web Application with identity. changing the version from ASP.NET Core 2.1 to ASP.NET Core 2.0 fixed the problem. I am using visual studio version 15.7.6, .NET Framework version 4.7.03056

like image 1
Rowan Berry Avatar answered Oct 24 '22 16:10

Rowan Berry