Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can redirect to a page located in a different folder using razorpages by:

  1. Specifying the path to the page in the Redirect method or IActionResult return value.

For example, if you have a page named "Index" in a folder named "Admin", you can redirect to it using the following code:

return RedirectToPage("/Admin/Index");

Note that the leading slash ("/") indicates the root folder of the application, and the folder and page name are separated by a forward slash ("/").

  1. You can also use the PageLinkTagHelper to generate a link to the page, and then use that link as the target for the redirect.

For example, if you have a page named "Index" in a folder named "Admin", you can generate a link to the page using the following code:

Admin Index

And then use the link as the target for the redirect:

return Redirect("/Admin/Index");