Home > OS >  .NET 5: It is possible to create a link to the Registration Razor Page inside a .cshtml file of an M
.NET 5: It is possible to create a link to the Registration Razor Page inside a .cshtml file of an M

Time:12-15

So I have this .NET 5 MVC application. However it is using Microsoft Identity. When I scaffold Identity pages, they are razor pages, which works fine anyway.

However I need to remove the link of the registration page from the login form to inside the application. I said, uh, that's easy, I just link to the razor page inside my custom user view. However I can't find a way to do this.

I have tried various code around this line:

<a asp-page="/Identity/Account/Register">Register a New User</a>

That "/Identity/Account/Register" path is not my invention. Is the url that I see in the browser after localhost when testing to click the register link inside login page.

I tried giving the full folder path, but it didn't work either :(

This is my Identity file structure:

Identity File Structure

And the .cshtml from where I'm trying to link the register page, is this index file inside the users folder:

cshtml file

How do I achieve this?

Thank you in advance.

CodePudding user response:

You need to add asp-area tag helper in your anchor tag.

<a asp-area="Identity" asp-page="/Account/Register">Register a New User</a>

You can also try

<a asp-page="/Account/Register">Register a New User</a>

I've answered a similar query here.

  • Related