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

Forums / Developing with Sitefinity / ResourceLinks Clarification

ResourceLinks Clarification

7 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    21 Feb 2012
    Link to this post
    ResourceLinks is handy for only loading a script once right?

    1) So is that also the case if you load via embedded resource, AND relative pathing
    2) Does relative pathing even work to only load it once?
    3) Can you allow .less to be served from the control as well?

    ResourceName property of the ResourceLinks has specified a resource with an invalid extension. Allowed extensions are: .css, .jpg, .jpeg, .gif, .png and .js

  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    24 Feb 2012
    Link to this post
    Hi Steve,

    All of the ways that you described load the resources once, until you edit them or rebuild the solution of your project. This depends on the StaticExpiration property of the browser. If it is enabled, then no matter how you load the scripts, they will always be cached in the browser, until they have been edited.
     As for the .less resources, I don't think that this would be possible as the control is internally built to load only the specified extensions.

    All the best,
    Svetoslav Petsov
    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
  3. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    24 Feb 2012
    Link to this post
    Hey Svetoslav,
     " As for the .less resources, I don't think that this would be possible as the control is internally built to load only the specified extensions."

    Yeah that's what I mean...can you change the allowed extensions on the control to allow LESS? :)
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    29 Feb 2012
    Link to this post
    Hi Steve,

     I just checked how the control works and it internally checks for the resource type and returns the specific type of resource. It all happens in this method:

    protected virtual WebResourceType GetResourceType(string resourceName)
            {
                if(string.IsNullOrEmpty(resourceName))
                    throw new InvalidOperationException(Res.Get<ErrorMessages>().ResourceLink_ResourceNameNotDefined);
     
                if(resourceName.IndexOf(".", StringComparison.OrdinalIgnoreCase) == -1)
                    throw new InvalidOperationException(Res.Get<ErrorMessages>().ResourceLink_ResourceNameMissingExtension);
     
                string resourceExtension = resourceName.Substring(resourceName.LastIndexOf(".", StringComparison.OrdinalIgnoreCase));
                if(!allowedExtensions.Contains(resourceExtension.ToLowerInvariant()))
                    throw new InvalidOperationException(Res.Get<ErrorMessages>().ResourceLink_ResourceNameInvalidExtension);
     
                string extension = resourceName.Substring(resourceName.LastIndexOf(".", StringComparison.OrdinalIgnoreCase));
                switch (extension.ToLower())
                {
                    case ".css":
                        return WebResourceType.StyleSheet;
                    case ".js":
                        return WebResourceType.JavaScript;
                    case ".jpg":
                    case ".jpeg":
                    case ".gif":
                    case ".png":
                        return WebResourceType.Image;
                }
     
                return WebResourceType.StyleSheet;
            }

    I suppose you could override this and change the returned type. However the check for the allowed type (if(!allowedExtensions.Contains... ) uses an internal List (allowedExtensions) which you won't be able to change, so you may need to change the whole logic for that particular method. However, all in all, I don't think this will work very well, as it will be too hacky. 

    All the best,
    Svetoslav Petsov
    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
  5. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    29 Feb 2012
    Link to this post
    Can you either just make that change in the code for 5.0, or just put in a PITS to add

    case ".less":
                        return WebResourceType.StyleSheet;

    ?
  6. John
    John avatar
    22 posts
    Registered:
    14 Jan 2011
    29 Feb 2012
    Link to this post
    Hello,

    I would like to custom the resource url in the ResourceLinks control to add some kind of versioning, just like you did for images, docs, etc in SF. This would avoid the browsing caching when I make a change in a resource (ie. a .css file) but still using the caching feature.

    The problem I'm facing is that I get this same error whenever I tried to add "?vrsn=1" at the end of the ResourceFile Name property. 

    Can I get this working somehow ?
    Thanks,
    John.

    The error:
    ResourceName property of the ResourceLinks has specified a resource with an invalid extension. Allowed extensions are: .css, .jpg, .jpeg, .gif, .png and .js

  7. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    02 Mar 2012
    Link to this post
    Hi,

     I logged in a feature request for the .less resources. Here's the PITS issue you can follow:
    http://www.telerik.com/support/pits.aspx#/public/sitefinity/10026 
    As for the versioning, this is a reasonable suggestion, so we will discuss it internally and see if it can be implemented in Sitefinity. Thanks. 

    Kind regards,
    Svetoslav Petsov
    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
7 posts, 0 answered