try implement and register in your IoC `EPiServer.Web.IAccessDeniedHandler`. It has `void AccessDenied(HttpContextBase context);` method that you can implement to handle access denied scenario for media content.
keep in mind that this service can be used in other scanrios as well, so you might need to fine tune checking HttpContext and fork handling logic.
I am new to Episerver and trying to figure out below mentioned issue.
I have implemented a 404 page based httperrors from web.config. I have implemented a custom access denied page so that users see this page instead of redirecting to start page. The reference used is from
This access denied logic works for page types but when I have a media file (pdf etc) on click of it, this still takes me to start page instead of access denied page.
Any inputs on how can I redirect to my access denied page instead of start page when navigating to a media file and user doesnt have appropriate access.