[URGENT] Problem getting a document when quering on MediaURL

Posted by Community Admin on 04-Aug-2018 10:19

[URGENT] Problem getting a document when quering on MediaURL

All Replies

Posted by Community Admin on 27-May-2011 00:00

Hello,
I'm using an httpmodule to increase the viewcount of a document, prior to SP1 it was working this way:

string urlPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
  var man = LibrariesManager.GetManager();
 
 
                        var cc = man.GetDocuments().FirstOrDefault();
 
                        var documents = man.GetDocuments().Where(o1 => o1.MediaUrl == urlPath );
 
                        if (documents.Count() > 0)
                        
                            int r = 0; //<- won't get here
                        


but now I'm getting this exception :

"Identifier 'MediaUrl' is not a parameter or variable or field of 'Telerik.Sitefinity.Libraries.Model.Document'. If 'MediaUrl' is a property please add the FieldAlias or Storage attribute to it or declare it as a field's alias."

how can I get a document starting from it's URL?

I've also tried with :

//var documents = entity.Documents().Where(o => o.Status == ContentLifecycleStatus.Live && o.MediaUrl == urlPath);
 
                       //var documentContainer = documents.Get();
 
                       //if (documentContainer.Count() > 0)

But this won't work anymore

Thanks

Posted by Community Admin on 01-Jun-2011 00:00

Hi Paolo,

In the code below you need to replace the row

var documents = man.GetDocuments().Where(o1 => o1.MediaUrl == urlPath );

with 

var documents = man.GetDocuments().ToList().Where(o1 => o1.MediaUrl == urlPath );

Let us know if you find any further issues!

Regards,
Milena
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed