Search code examples
c#asp.netasp.net-coreasp.net-identity

How to navigate from identity page to page in different folder


I have an ASP.NET Web Application (using Razor pages not controllers) and I am trying to amend the register (identity) page so that once the user has registered (by an admin whos logged in already) it navigates to a Manage roles page and passes the UserId of the user just created.

This is my folder structure:

FOLDER STRUCTURE

Currently I'm on the register page which is within the following path:

Areas/Identity/Pages/Account/Register.cshtml

and I am trying to navigate to a page thats simply within the Pages folder: Pages/ManageRoles.cshtml

Here is my code:

return RedirectToPage("./ManageRoles", new { id = user.Id });

but it doesn't work and gives me an error saying No page named './ManageRoles' matches the supplied values. I have also tried the code without the ./ and it still gave me the same error. I have also tried it without the userId part and it still didnt work.

Could someone help me?


Solution

  • Changed it to this and it worked:

    return RedirectToPage("/ManageRoles", new { UserId = user.Id });