ResourceLinks/ResourceFile allowed extension hack

Posted by Community Admin on 04-Aug-2018 12:14

ResourceLinks/ResourceFile allowed extension hack

All Replies

Posted by Community Admin on 24-Nov-2011 00:00

Hi,

Just wanted to share a little something that made my life easier.

The following code does not work:

<sf:ResourceLinks ID="resourceLinks" runat="server" UseEmbeddedThemes="false">
    <sf:ResourceFile Name="~/MyStyle.ashx" Static="true" />
</sf:ResourceLinks>

This fails because the control checks the file extension, and only allows certain extensions (.css, .jpg, .jpeg, .gif, .png and .js). Not ashx.

I've hit this limitation several times trying to integrate some of our old stuff into Sitefinity.
I just found a nice workaround to this issue:

<sf:ResourceLinks ID="resourceLinks" runat="server" UseEmbeddedThemes="false">
    <sf:ResourceFile Name="~/MyStyle.ashx?ext=.css" Static="true" />
</sf:ResourceLinks>

This works, as you fool the control by adding a query string parameter, making it think the file extension is css.

Posted by Community Admin on 25-Nov-2011 00:00

+1 NICE FIND! :)

This thread is closed