Reputation: 367
I have an ASP.NET Core application which has a base controller. Inside the base controller, I use the OnActionExecutionAsync overridden method to re-direct the user to an external URL if a condition matches and when I call the redirect URL I also pass the original URL as parameter. How can I get the original request URL from my base controller, or more specifically from the OnActionExecutionAsync method of my controller?
Upvotes: 0
Views: 474
Reputation: 239340
Anywhere in the controller you have access to the Request
property, which contains all the components of the requested URL. It's not clear what exactly you need, but there's the usual suspects of Scheme
, Host
, Path
, QueryString
, etc. If you're looking for the full URL. You can use UriHelper.GetDisplayUrl(Request)
.
Upvotes: 2