locked
Can I scaffold an mvc version of Identity into an mvc project? RRS feed

  • Question

  • User-2105652292 posted

    [OVERVIEW]

    [] I am building a new dotnet 3.x MVC project using Visual Studio Code(VSC) and the sqlite database. I want to use the Identity system for Authentication with individual user accounts.

    [] I plan to override some of the default methods and UI of the Identity system to extend the functionality

    [PROBLEM=]

    [] When I use the app generator "dotnet new mvc" with the switches (--auth individual) it builds the default Razor Class Library(RCL) identity system.

    [] This implementation works fine, However, I would prefer to have a consistent programming model throughout the application, versus having a mix of @pages and mvc.

    [ALSO TRIED=]

    [] I have also tried building the app without the Identity system and then scaffolding it in as per the document Scaffolding Identity in ASP.net core projects ] This also added the RCL version

    [?QUESTION=?]

    [] Is there currently a method that I can use to generate an MVC implementation of the Identity system VS the Razor Pages implementation?

    Tuesday, October 15, 2019 6:55 PM

All replies

  • User711641945 posted

    Hi Don_S,

    If you scaffold the identity in MVC project,it generates razor pages.This is by design.

    Here is an official sample on github about generate an MVC implementation of Indentity system without razor pages:

    Reference:

    https://github.com/aspnet/Identity/tree/master/samples/IdentitySample.Mvc

    Best Regards,

    Rena

    Wednesday, October 16, 2019 3:26 AM
  • User-821857111 posted

    [] This implementation works fine, However, I would prefer to have a consistent programming model throughout the application, versus having a mix of @pages and mvc.
    Then use Razor Pages. These days, the recommended way to generate server-side HTML is via Razor Pages. Controllers are used for Web APIs.

    https://odetocode.com/blogs/scott/archive/2019/09/12/net-core-opinion-14-razor-pages-for-html-controllers.aspx

    Wednesday, October 16, 2019 7:12 AM
  • User-2105652292 posted

    Thank you for the reply Rena

    I did come across the sample MVC implementation you linked and I have used it manually create a partial mvc implementation of Identity in my app that is functional.

    I "assumed" or "was hoping" that there was a way to scaffold the mvc version of Identity into a new mvc project and that I was missing it or doing it incorrectly.

    Your saying that it does not exist currently and the only way to scaffold identity will generate the RCL implementation of it.

    Any idea of if "scaffolding identity" is something that is planned or not?

    Thanks again

    Wednesday, October 16, 2019 1:30 PM
  • User-2105652292 posted

    Thank you for the reply Mike

    This project needs to be MVC.

    BTW, Excellent article you linked on some of the advantages of the new Razor pages model - using the Identity system as an example!

    Thanks again!

    Wednesday, October 16, 2019 1:46 PM
  • User-821857111 posted

    Any idea of if "scaffolding identity" is something that is planned or not?
    Unlikely. It was MVC until they released Razor Pages. Then they made a deliberate decision to ditch the MVC version (on the basis that Razor Pages is the recommended framework for server-side UI generation), so it is highly unlikely that they will reintroduce it, IMO. 

    You could always raise an issue on Github requesting this. You might even find an existing one that you can upvote. 

    Wednesday, October 16, 2019 2:02 PM
  • User475983607 posted

    The ASP.NET Core 2.0 SDK has Identity which includes MVC source code.  If you have 2.0 installed, create a project that targets 2.0 and select the individual account option to get the template code.  The down side is upgrading manually to the latest framework and Bootstrap 4.0.

    There's also Google.  I'm sure someone has done the work already.

    Wednesday, October 16, 2019 4:29 PM