403 errors when referencing theme assets from HTML

Posted by Community Admin on 03-Aug-2018 13:21

403 errors when referencing theme assets from HTML

All Replies

Posted by Community Admin on 20-Sep-2010 00:00

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?

Posted by Community Admin on 21-Sep-2010 00:00

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

Posted by Community Admin on 21-Sep-2010 00:00

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.

Posted by Community Admin on 21-Sep-2010 00:00

It works now, but the documentation should be updated to reflect this restriction.

Posted by Community Admin on 21-Sep-2010 00:00

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

Posted by Community Admin on 22-Sep-2010 00:00

Yes, that did the trick. Thank you.

This thread is closed