locked
How do you scaffold controllers for identity pages ? RRS feed

All replies

  • Wednesday, September 4, 2019 10:53 AM
  • User-821857111 posted

    ASP.NET Core Identity UI is implemented as Razor Pages, not MVC controllers and views. If you want to use MVC to manage the Identity workflow, you will have to write your own controllers and views.

    Microsoft are recommending that people move away from MVC for traditional server-side web apps these days. Razor Pages is the recommended framework.

    Wednesday, September 4, 2019 3:02 PM
  • User-973886032 posted

    Microsoft are recommending that people move away from MVC for traditional server-side web apps these days. Razor Pages is the recommended framework.

    Do you know why ?

    I used to do classic asp, then asp.net and then moved to MVC a few years ago, seems we are going round and round in circles ???

    Wednesday, September 4, 2019 3:05 PM
  • User475983607 posted

    Create a new project that targets ASP.NET Core 2.0 templates and use the Individual Account option.  This will produces scaffolded Actions and Views.  Form there you can upgrade to Core 2.2.

    Wednesday, September 4, 2019 4:00 PM
  • User711641945 posted

    Hi afrika,

    As mike said,the default UI of Identity is razor page.So you need to write your own controllers and views.

    I suggest that you can go to the official ASP.NET Core Identity Github Repository (https://github.com/aspnet/Identity) and download it. Open the solution and search for the IdentitySample.Mvc project. Copy the necessary files to your project.

    NotesDon't forget to change the namespace on the added files since they belong to a different project.

    Best Regards,

    Rena

    Thursday, September 5, 2019 2:24 AM
  • User-637833180 posted
    What about web api controllers that expose identity models for use by a SPA project
    Thursday, September 5, 2019 3:53 AM
  • User-821857111 posted

    Mikesdotnetting

    Microsoft are recommending that people move away from MVC for traditional server-side web apps these days. Razor Pages is the recommended framework.

    Do you know why ?

    I used to do classic asp, then asp.net and then moved to MVC a few years ago, seems we are going round and round in circles ???

    Razor Pages is a simpler approach to developing applications that are chiefly concerned with server-side HTML generation. The MVC framework was introduced because enterprise devs had massive problems bending the Web Forms system to their will, which at that time focused on taking a Test Driven Development approach to producing applications. Also, Web Forms was very difficult to adapt or customise. So they eschewed Microsoft technologies in favour of Ruby On Rails and other frameworks that promoted loose coupling and extensibility. Most of these frameworks used the MVC pattern, being a well established presentational pattern. So MS introduced their own MVC-based framework to solve the problems. 

    MVC is fine, but there is nothing specific to MVC that makes it a better framework for loose coupling, extensibility etc. You can design an MVC-based framework with all the problems that Web Forms had, if you wanted. MS could just as easily have produced a new page-focused framework, but MVC frameworks were popular at the time.

    MVC has its problems too. It has a relatively high concept count. You need to understand how the various abstract parts of the pattern work together. Then you need to understand how URLs are matched to controller actions. You have folders all over the project that have nothing to do with the structure of the application, and everything to do with the conventions of the framework. Controllers are increasingly responsible for processing requests on behalf of multiple views, in conflict with the Single Responsibility principal.

    Razor Pages offers a much simpler approach to app development, where a URL matches a file path of disk, and there is a one-to-one mapping between the controller (PageModel class) and the view (Razor Page). It is a pattern that is familiar to classic ASP, PHP, Web Forms, JSP developers, and is more intuitive to newcomers to web development. and yet. Razor Pages provides just as much lose coupling and extensibility as MVC ever did.

    Basically, it's Web Forms done properly.

    Thursday, September 5, 2019 9:15 AM
  • User-973886032 posted

    Basically, it's Web Forms done properly.

    sounds very disappointing to me, as its going round and round in circles. 

    I know 2 people who stayed with classic ASP to this day, and it seems MS keeps moving the goal post thereby increasing the learning curve. I wonder what next ? cry

    Thursday, September 5, 2019 5:22 PM
  • User475983607 posted

    Again, the ASP.NET Core 2.0 SDK has the template you are looking for.

    Thursday, September 5, 2019 5:54 PM
  • User-474980206 posted

    you want the following:

     https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.2&tabs=visual-studio

    see the create full identity ui source. you probably want the identity actions to return json rather than html and use JWT authentication.  here is a simple example:

      https://jasonwatmore.com/post/2018/08/14/aspnet-core-21-jwt-authentication-tutorial-with-example-api

     

    Thursday, September 5, 2019 7:39 PM
  • User-821857111 posted

    I know 2 people who stayed with classic ASP to this day, and it seems MS keeps moving the goal post
    It's called progress. At some point, Razor Pages will no doubt make way for something else.

    But the good news is that MS continue to provide support for your classic ASP friends. 

    Thursday, September 5, 2019 8:53 PM