More in this section

Forums / General Discussions / 403 errors when referencing theme assets from HTML

403 errors when referencing theme assets from HTML

6 posts, 2 answered
  1. Klemen Slavič
    Klemen Slavič avatar
    30 posts
    Registered:
    24 Jul 2009
    20 Sep 2010
    Link to this post
    Hello,

    I have a problem using images and CSS files in master pages. Whenever I link to certain files, eg. a logo using something like:

    <img src="/MyProject/App_Data/Sitefinity/WebsiteTemplates/MyTemplate/App_Themes/MyTheme/Images/logo.png" alt="logo"/>

    ...I get a 403 error for the file. Setting background images from CSS does work. Same goes for <link/> tags in the <head/> element (although auto-include works for Layout.css, so that's what I did for this template).

    Is this an effect of a hotlink-protection system in 4.0beta? There's always applying background images through CSS, but IMHO logos and images that are semantically valid should be available to include using master links.

    Is there a way around this effect?
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    21 Sep 2010
    Link to this post
    Hello Klemen Slavič,

    Thank you for using our services.

    The App_Data folder is a special folder in ASP.NET with special permissions. Its purpose is to serve as data store (mainly for db files and xml schemas). It is protected from direct linking and probably this is why you are experiencing problems when try references images in App_Data. Can you try copying the images in some other path and linking them?

    Kind regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  3. Klemen Slavič
    Klemen Slavič avatar
    30 posts
    Registered:
    24 Jul 2009
    21 Sep 2010
    Link to this post
    I see, I've been mislead by the 4.0 beta documentation. Quote:

    Example: Including a Reset.css file for a theme as a link.
     
    <link href="~/App_Data/Sitefinity/WebsiteTemplates/DefaultTemplate/DefaultTheme/Global/Reset.css" type="text/css" rel="stylesheet" />

    Page 7 of Designer's Guide 4.0.

    I'll try creating a folder in the root directory and linking from there.
  4. Klemen Slavič
    Klemen Slavič avatar
    30 posts
    Registered:
    24 Jul 2009
    21 Sep 2010
    Link to this post
    It works now, but the documentation should be updated to reflect this restriction.
  5. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    21 Sep 2010
    Link to this post
    Hello Klemen Slavič,

    Thank you for getting back to me.

    The css files are served because you have registered the theme and Sitefinity is rerouting the paths not to be pointing to App_Data. If you examine the locations of the loaded CSS files on your page they will be something like: /Sitefinity/WebsiteTemplates/University/App_Themes/LightGreen/global/main.css. Also images contained in your theme's css are also rerouted and loaded without the App_Data in the path. So you should be able to link to the image with:
    <img src="/MyProject/Sitefinity/WebsiteTemplates/MyTemplate/App_Themes/MyTheme/Images/logo.png" alt="logo"/>

    We are going to update our documentation accordingly.

    Best wishes,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  6. Klemen Slavič
    Klemen Slavič avatar
    30 posts
    Registered:
    24 Jul 2009
    22 Sep 2010
    Link to this post
    Yes, that did the trick. Thank you.
6 posts, 2 answered