question

DONNELLYBrian-3899 avatar image
0 Votes"
DONNELLYBrian-3899 asked YiyiYou-MSFT answered

Redirect To Page with Anchor tag

I am trying to figure out how to redirect to a razor page and have an anchor tag attached to the URL.

My code:

public IActionResult OnPost()
{
return RedirectToPage("Detail",
new
{
id = applicant.applicantId
})
}

This takes the user to the detail page with an id like so: /Detail?id=098776

What I actually need is to send the user to an Anchor in the page like this: /Detail?id=098776#thisplaceinpage

Anyone know how I would make that happen with the code above?


dotnet-aspnet-core-generaldotnet-aspnet-core-razor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YiyiYou-MSFT avatar image
0 Votes"
YiyiYou-MSFT answered

Hi,@DONNELLYBrian-3899

You can refer the official doc,and pay attention to RedirectToPage(String, String, Object, String),You can add Anchor tag to string fragment.Here is a demo:
handler:

 public IActionResult OnPost()
         {
             return RedirectToPage("Detail","",new{id = 1}, "thisplaceinpage");
         }

result:
106750-6-18-1.gif






If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best Regards,
YiyiYou


6-18-1.gif (120.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.