As far as I can tell, LoginPath
is of type PathString
and can only represent a path. Characters that can't be represented in the path, such as #
, will be always be encoded.
The workaround as suggested by @AgaveJoe , is to link to a controller action that can then redirect to the appropriate page with the fragment:
[AllowAnonymous]
public IActionResult LoginModal() { return Redirect("/#loginModal"); }
One can take the return path as a parameter here and append it as well, but it is not used in my case.