Deleted media item causing database hits when referenced in partial views
Hello guys,
We're currently in the final throws of preparing an Umbraco 7 site for launch, and checking/chasing performance improvements.
On using miniprofiler, I noticed a partial view on our site home page was responsible for hitting the database with SQL queries. Given that I thought most of the front-end stuff in Umbraco didn't touch the database, I thought it was a bit strange.
After looking in to the problem, it seems to be because a couple of media items referenced by a content page, had been deleted from the "Media" tab.
If this happens, then just doing something like...
Is there something wrong with the way we're accessing Media? Is there some way to check if a media item has been binned without causing a database query to happen?
Deleted media item causing database hits when referenced in partial views
Hello guys,
We're currently in the final throws of preparing an Umbraco 7 site for launch, and checking/chasing performance improvements.
On using miniprofiler, I noticed a partial view on our site home page was responsible for hitting the database with SQL queries. Given that I thought most of the front-end stuff in Umbraco didn't touch the database, I thought it was a bit strange.
After looking in to the problem, it seems to be because a couple of media items referenced by a content page, had been deleted from the "Media" tab.
If this happens, then just doing something like...
Model.Content.Brochure.Url
... causes a database hit.
I also tried:
Umbraco.TypedMedia(Model.Content.GetProperty("brochure").DataValue)
... but still a database query is initiated.
Is there something wrong with the way we're accessing Media? Is there some way to check if a media item has been binned without causing a database query to happen?
Many thanks,
Steve.
is working on a reply...