Paul Duer
Paul Duer

Reputation: 1120

How to use RedirectToPage with a default handler that requires a parameter?

I'm using Razor Pages on .Net Core 2.2 and I have the following handler defined on an Index page:

 public async Task OnGetAsync(string legalDocSubType)

and I am trying to use RedirectToPage to go to this page with:

return RedirectToPage("./Index", "legalDocSubType", PublishRecord.LegalDocSubType);

which produces this URL portion:

/Publishing?handler=legalDocSubType

which is wrong, I wanted:

/Publishing?legalDocSubType=Module

So I don't understand what I have done wrong? I want to be able to redirect to this index page and pass my querystring.

Upvotes: 0

Views: 1273

Answers (1)

John-Luke Laue
John-Luke Laue

Reputation: 3856

Might it be this?

return RedirectToPage("./Index", new { legalDocSubType = "Module" } );

Upvotes: 4

Related Questions