Generate Url to Razor Page in Area from Razor View
Asked Answered
L

2

8

Within Razor View, I want to generate Url to specific Razor Page which is located in some Area.

I have already trying using this

@Url.Page("/Areas/Identity/Pages/Account/Manage/Orders", new { id = @Model.Id })

but what I get in return is

http://localhost:8888/Order/Submit/12345?page=%2FAreas%2FIdentity%2FPages%2FAccount%2FManage%2FOrders

while I would need this:

http://localhost:8888/Identity/Account/Manage/Orders?id=12345

Is it correct to assume that the only way to solve it is to apply customer routing? If yes, what would be the way? Thanks.

Lakisha answered 6/5, 2019 at 20:4 Comment(3)
@Url.Page("/Pages/Account/Manage/Orders", new { area = "Identity", id = @Model.Id }) should do it, I think.Adept
Actually I'm not sure you need /Pages at the start either...Adept
without /Pages that works! thank you very much :)Lakisha
S
11

This should do the trick:

@Url.Page("/Account/Manage/Orders", new { id = Model.Id, area = "Identity"})
Secondly answered 7/5, 2019 at 13:15 Comment(0)
W
0

PageLink creates only absolute URLs.

@Url.PageLink(
    "Pages/Account/Manage/Orders",
    values: new { area = "Identity", id = @Model.Id });
Whichever answered 11/9, 2023 at 17:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.