I need it to compare a list of existing media.Urls()'s to the incoming httphandler.
So I take out a complete list of mediaurls from the umbraco context.
When the httphandler is called, it should compare the current request to the list of media, to see if the media it is calling is protected.
Everything else works, but the comparison.
Why should'nt I use the code? Is there a risk?
I actually don't know what to do if context doesnt work, then I might have to make a cronjob and a controller which fires lists into a DB entry every 5 minutes.
If you take the complete list of all media urls, your site might because massively slow! You should do as less lookups as possible. Also, most of the media files exists on disk. So you could check if the file exists on disk to continue with your handler.
If you need to protect media, also consider a package like Media Protect.
I ended up stuffing it all into the ApplicationEventHandler with ContentService_Published. Seems to work.
Also installed Entity Framework to put all content into a separate table.
Shouldnt be any problems with Umbraco.Context and ApplicationEventHandler as far as you know..?
Umbraco.Context is null
Hi there.
Im building a iHttpHandler based on the tutorial here:
https://www.steadygo.digital/blog/securing-media-files-umbraco-7-5-2/
My problem is that Im adding a function which needs info from:
When I add that helper I get an error:
Does anyone know why theres no value i UmbracoContext? I have put the code in App_Code.
The code is run from the webconfig in the media folder:
Hi
The UmbracoContext is the current umbraco request. Because the request is not entered into umbraco yet, you can not use the UmbracoHelper.
What you could do, but I would not suggest to walk this way.
What do you need this for?
Kind regards
Damiaan
I need it to compare a list of existing media.Urls()'s to the incoming httphandler.
So I take out a complete list of mediaurls from the umbraco context. When the httphandler is called, it should compare the current request to the list of media, to see if the media it is calling is protected. Everything else works, but the comparison.
Why should'nt I use the code? Is there a risk?
I actually don't know what to do if context doesnt work, then I might have to make a cronjob and a controller which fires lists into a DB entry every 5 minutes.
Yes, there is a risk.
If you take the complete list of all media urls, your site might because massively slow! You should do as less lookups as possible. Also, most of the media files exists on disk. So you could check if the file exists on disk to continue with your handler.
If you need to protect media, also consider a package like Media Protect.
Kind regards
okay. I have to think about what to do from here.
Thanks for your input, Damiaan, really appreciate it.
:-) /Peter
Good luck. You aren't tackling the easiest thing.
I ended up stuffing it all into the ApplicationEventHandler with ContentService_Published. Seems to work. Also installed Entity Framework to put all content into a separate table.
Shouldnt be any problems with Umbraco.Context and ApplicationEventHandler as far as you know..?
Please read https://our.umbraco.org/documentation/Reference/Common-Pitfalls/ there is section on newing up UmbracoContext.
Regards
Ismail
Thanks Ismail. Thats interesting reading. Havent seen that, though I should. A new approach might be needed for this project.
Seems I was lucky this time. My script is accessing via this:
"access each of these services from their own singleton constructs: UmbracoContext.Current and ApplicationContext.Current."
Thanks for input both of you guys.
is working on a reply...