How to capture header referer before authentication redirect

Matt Misner 1 Reputation point
2021-04-15T10:22:28.953+00:00

Trying to capture the referer page so that I can redirect the user back to where they came from. Using identity server 4 in the Razor Pages client web application. When a user goes to a page requiring authorize, they sent to identity server 4, then are redirected back to the authorize page. On that authorize page on the client I am unable to know where the user came from originally in the client app. I have read some solutions that use an authorize filter to save the referer in session before being redirected to identity server 4, but I believe it is an MVC solution. When I tried implementing in Razor Pages, the custom authorize filter doesn't get called before I get redirected to identity server 4. Is there a filter or point in the pipeline in Razor Pages where I can save the referer in session before getting redirected to Identity Server 4?

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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.