Redirect To Page with Anchor tag

DONNELLY Brian 21 Reputation points
2021-06-17T20:04:24.45+00:00

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?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,148 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yiyi You - MSFT 521 Reputation points
    2021-06-18T02:32:02.42+00:00

    Hi,@DONNELLY Brian

    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

    0 comments No comments

0 additional answers

Sort by: Most helpful