0

I created a simple aspx page and I assigned the background image for my page using css as below:

html {
    background: url(Images/backImage.jpg) no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
}

The styles are in the style tag with the aspx page itself. I can see the image in the designer, but when I open the page in browser, I am not able to view the image. It happens in all the browsers I tried. What am I missing here?

doitlikejustin
  • 6,293
  • 2
  • 40
  • 68
PushCode
  • 1,419
  • 3
  • 15
  • 31

3 Answers3

1

edit: You need quotes

background: url("Images/backImage.jpg")

Also try Fully qualifying your url to the image.

Automate This
  • 30,726
  • 11
  • 60
  • 82
  • 1
    You only *need* quotes if you have unescaped special characters: http://stackoverflow.com/questions/2168855/css-url-are-quotes-needed – Grim... Aug 15 '13 at 19:30
  • No worries. Always adding quotes isn't a bad habit to get into. – Grim... Aug 15 '13 at 19:35
  • @Grim I tried your options. I still can't see the image in browser. I have this error in my browser console: Resource interpreted as Image but transferred with MIME type text/html – PushCode Aug 15 '13 at 19:39
0

If you are in a Linux environment your directory file name need to be case sensitive.

If your image directory on your server is "images" then "Images" wont work. I have pulled my hair out on that one a few times.

Travis
  • 2,185
  • 7
  • 27
  • 42
0

I found it. Its not actually related to css. I am using forms authentication in my web application I have set protection to all my resources as:

<forms name=".ASPXFORMSDEMO" loginUrl="logon.aspx" protection="All" path="/" timeout="30" />

I realised that I need allow unauthenticated users to access images folder and added the following in my web.config after the system.web tag:

<location path="images">
<system.web>
  <authorization>
    <allow users ="*" />
  </authorization>
</system.web>

Thank you all for your quick replies and I am sorry for missing out the details in my actual question. I didn't really thought it was related to authentication.

PushCode
  • 1,419
  • 3
  • 15
  • 31