Reputation: 1451
I,am developing an Asp.net website and have struck in an surprise thing. My Folder structure is as shown below:
- Styles
- master.css
- Images
-webPages
-scripts
Now when i try to access an image in images folder from css, i get "Failed to load resource: the server responded with a status of 404 (Not Found) " error in chrome. The error only comes from the css file. I have used some images in my asp.net pages.It is working fine there.My example code for accessing an image in css is below
a.close { background-image: url(/images/close-arrow.png); background-position: left center; padding: 0 0 0 25px; }
I cannot understand what the problem is. Please Help me to sort this problem. Thanks in Advance
Upvotes: 0
Views: 2355
Reputation: 1
Put this code snippet in your web.config
:
<location path="Images">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Upvotes: 0
Reputation: 1275
/images/close-arrow.png is not really a relative path. The leading / tells the script to start from your webroot. Just remove it and it is loaded relatively from the Styles folder
Upvotes: 0
Reputation: 1095
You have to mention path as background-image: url(./images/close-arrow.png);
because this is relative path.
Upvotes: 1