2

How can one include an Area in the UrlHelperExtensions.Page Method?

The docs don't mention areas.

When I want to link to a page in an area (in my case Identity) the page name is not found:

var callbackUrl = Url.Page(
            "/Identity/Account/ResetPassword",
            pageHandler: null,
            values: new {code},
            protocol: Request.Scheme);

callback is null and I don't know how to specify that the page is outside of my normal Razor Pages Pages-Folder.

Community
  • 1
  • 1
Bijan
  • 25,559
  • 8
  • 79
  • 71

1 Answers1

2

The documentation on this is very poor. You can specify the area inside your values like this:

var callbackUrl = Url.Page(
        "/Identity/Account/ResetPassword",
        pageHandler: null,
        values: new { code, area = "Identity" },
        protocol: Request.Scheme);
  • Weird but my generated url from above code is as follows: https://localhost:44346/?area=Identity&code=CfDJ8OZvPv5w8uZOu6N%2F9ZZs6M6acPTC44cfIzoWbKWavmOoETCDq1FntmC%2FfhltzqyfHHP1015wHVRoChFrkq7sjEW8CAYAMkn4hroyFDAMPmdPNRAKitbujWKcHfVQs9bEWPXk%2Fq2iIgLWsZWm9k%2Fs%2BWbtehMB%2BCQimdR17dAcgT3YHnE5w569OltZFArdgZPmvA%3D%3D&page=%2FIdentity%2FAccount%2FResetPassword – Nabeel Apr 20 '23 at 19:51