The framework is encoding your string. %2F is a "/" and %23 is a "#". Look into routing templates with Razor Pages.
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-9.0
A target page that receives the redirect.
@page "{id}/{bookmark}"
@model RazorPagesDemo.Pages.Page2Model
@{
}
<h1>Route Paramters</h1>
<p>Id: @Model.id</p>
<p>Bookmark: @Model.bookmark</p>
Bind the route parameters to properties.
[BindProperty(SupportsGet = true)]
public int id { get; set; }
[BindProperty(SupportsGet = true)]
public string bookmark { get; set; } = string.Empty;
The page that redirects to Page2
public RedirectToPageResult OnGet()
{
return RedirectToPage("Page2", new { id = 42, bookmark = "#bookmark" });
}
Typically, the "#" is a bookmark on a page.
https://www.w3schools.com/html/html_links_bookmarks.asp
It is not clear from your post how the "#" is supposed to work.