More in this section

Forums / Developing with Sitefinity / ResourceLinks/ResourceFile allowed extension hack

ResourceLinks/ResourceFile allowed extension hack

2 posts, 0 answered
  1. Thomas
    Thomas avatar
    223 posts
    Registered:
    19 Jan 2011
    24 Nov 2011
    Link to this post
    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.
  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    25 Nov 2011
    Link to this post
    +1 NICE FIND! :)
2 posts, 0 answered