Ask Your Question
4

How can I redirect to a page located in a different folder using razorpages?

asked 2023-05-19 00:58:39 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-05-19 01:06:02 +0000

djk gravatar image

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");

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-19 00:58:39 +0000

Seen: 15 times

Last updated: May 19 '23