How do I gain access to the http context using an event handler

Topics: Customizing Orchard
May 6, 2015 at 2:15 AM
I need to send a user to a different page after login depending on their role. To do this I created an implementation of the IUserEventHander and LoggedOn method. How do I get the http context in this method so that I can change the redirect request URL or is there a better way to do this?
May 6, 2015 at 3:39 AM
In your class that inherits from IUserEventHander, you can declare an IHttpContextAccessor, inject it through your constructor, and use it in other methods
    private readonly IHttpContextAccessor _httpContextAccessor;

    public YourConstructor(..., IHttpContextAccessor httpContextAccessor, ...) {
        _httpContextAccessor = httpContextAccessor;
   var httpContext = _httpContextAccessor.Current();