1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / [URGENT] Problem getting a document when quering on MediaURL

[URGENT] Problem getting a document when quering on MediaURL

2 posts, 0 answered
  1. Paolo
    Paolo avatar
    147 posts
    Registered:
    11 Jun 2009
    27 May 2011
    Link to this post
    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
  2. Milena
    Milena avatar
    75 posts
    Registered:
    05 Apr 2017
    01 Jun 2011
    Link to this post
    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
2 posts, 0 answered