nikib3ro
nikib3ro

Reputation: 20606

Get RedirectToPage Generated URL ASP.NET Core

You are able to redirect to other actions using built-in methods like:

RedirectToPage("./Index", new { StatusMessage = "Everything was processed successfully"" });

This will redirect to another PageModel that's in same directory and it's Index action. Is it possible to "extract" this functionality so that you get redirect location by just passing ./Index to some util function/method?

Upvotes: 0

Views: 247

Answers (1)

Moien Tajik
Moien Tajik

Reputation: 2321

public class IndexModel : PageModel
{
    public void OnGet()
    {
        string privacyPageUrl = Url.Page("./Privacy");
    }
}

Upvotes: 2

Related Questions