skip to Main Content

I am currently working on an ** MVC Core project using .Net8 preview**. Everything on the project works fine except the pages included after scaffolding identity. i.e Login, Register etc. When I navigate to loginRegister page for example, the default layout of my app doesn’t load. Meaning my navbar and footer is not displayed. Instead a blank navbar is displayed with nothing but the project name and Login/Register button at top. But on all the razor views everything works find.

What I have also noticed is that if I try to edit the Login.cshtml page, the changes doesn’t reflect on the UI. (Not related to HotReload). Even if I clean, rebuild or restart visual studio, the changes don’t reflect when login page is loaded. For example I modified this simple h2 on login.cshtml

From

your text

Use a local account to log in.

To

<h2>Use223 a local account to log in.</h2>

Nothing happens. I don’t know if the Account pages are being loaded from another location other than the folders in my project.

  • I have tried scaffolding identity several times from several previous versions of the project, and end up with same issue.
  • I have mapped razor pages in Program.cs file
    _ I have correctly specify the layout page in ViewStart file inside Accounts folder

@{ Layout = "~/Views/Shared/_Layout.cshtml"; }

What’s even weirder is that if i add a breakpoint to the constructor in login page model, i never hit that breakpoint even though the login page loads. So in theory I don’t think the pages are being loaded from the ones in my project. Otherwise I’ll definitely hit the breakpoints set. I even deleted the entire Identity folder under areas. But the login page still loads.

Here is a link to my project

https://github.com/KenJanka/Bulky_Login_UI_Issues

2

Answers


  1. Chosen as BEST ANSWER

    Finally resolved the issue. Turns out that the version of .Net 8 preview
    i have installed requires at least visual studio 2022 17.6 preview 2. I was using vs 2022 17.5.5. After upgrading to 17.6 preview 6, the issue went away and scaffolding identity works perfectly now.


  2. Since I do not have any code to work with, I will use generic theory.

    When you are on MVC, you will notice that in the views/shared folder you can see a layout there.

    The scaffolded Identity is all Razor pages that use a unique routing sequence. Some even come with their own layout page, and might even want their own DB COntext.

    You can however confirm what is using what layout by going to their views. In each view page, there should be a "Layout" that accepts the Layout path.

    The layout page is where the Navigation is typically stored. its default is mostly;

     Layout = "~/Views/Shared/_Layout.cshtml";
    

    As for the login button, it is most times a partial view that is referenced from the layout page.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search