ResourceLinks Clarification

Posted by Community Admin on 04-Aug-2018 21:38

ResourceLinks Clarification

All Replies

Posted by Community Admin on 21-Feb-2012 00:00

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

Posted by Community Admin on 24-Feb-2012 00:00

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

Posted by Community Admin on 24-Feb-2012 00:00

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? :)

Posted by Community Admin on 29-Feb-2012 00:00

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

Posted by Community Admin on 29-Feb-2012 00:00

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;

?

Posted by Community Admin on 29-Feb-2012 00:00

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

Posted by Community Admin on 02-Mar-2012 00:00

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

This thread is closed