Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
Hi every body
I'm working on a Web Application in Visual Studio 2010 and IIS7. For some reason the CSS only works properly inside visual studio. I can see the CSS inside the design view of the page. When I view the page on localhost the CSS is not being applied.
can anyone help me?

I think understood the cause of this problem.
this code in web.config has created my problem .
XML
<authentication mode="Forms">
        <forms loginUrl="Login.aspx" />
    </authentication>
 <authorization>
     <deny users="?"/>
 </authorization>

When I am on the login page style is not displayed but when I logged in the default page is working properly.
When I press the back key ,login page also works well.
What should I do?
However, when I remove the code below everything works well.
XML
<authorization>
        <deny users="?"/>
    </authorization>

best regards
Posted
Updated 16-Jul-17 23:16pm
v3
Comments
R. Giskard Reventlov 26-May-11 8:09am    
Is the path correct?
fika_fa 26-May-11 8:12am    
yes
thatraja 26-May-11 15:03pm    
Post your code in your question
fika_fa 27-May-11 9:47am    
I think understood the cause of this problem.please read my question again.I've changed it.

Verify the CSS has been loaded properly, the correct path has been used. You may also need to clear the browser cache just in case there is a conflict. If you are using IE you can use the Developer Toolbar to look at what scripts and CSS is actually loaded.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 26-May-11 20:42pm    
Good advice, my 5.
See also my short advice on how to do the check up and locate the lost resource.
--SA
_Amy 24-May-13 0:24am    
+5!
In addition to the answer by Mark:

You can ultimately what resource is found or not from the client side. Load the page, use "View Page Source" and locate the URL for CSS (or what ever else). It it looks correct, go to the address line and modify to load that resource directly. This page will be found or not. From that point, you know where to find a bug.

—SA
 
Share this answer
 
Comments
fika_fa 27-May-11 9:40am    
thanks for the help

I think understood the cause of this problem.please read my question again.I've changed it.
_Amy 24-May-13 0:25am    
You can accept the answers(Green Button), if it helped you. :)
Sergey Alexandrovich Kryukov 24-May-13 1:04am    
I see, thank you. My answer remains the same; and you should do the same, only pay attention of how your CSS is referenced from resulting HTML. Probably, this is just the issue of correcting the relative path of CSS in HTML.
—SA
_Amy 24-May-13 0:24am    
+5!
Sergey Alexandrovich Kryukov 24-May-13 1:04am    
Thank you, Amy.
—SA
I know this post has been open for a while, but I had the same problem and due to the research by fika_fa, I was able to identify and solve the problem at least for me.

The authorization that denies users access to the site also denies the loading of assets in folders that are restricted. So in my case the stylesheet was located in a folder called css. This meant that I needed to add an authorization configuration to the web.config to allow anonymous users to be able to access it, thus being able to load the stylesheet.

After the system.web section in the web.config I added the following lines:

XML
<location path="css">

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

  </location>



This solved the problem for me and hopefully if you came here and the above solutions didn't help this will help you.

http://weblogs.asp.net/gurusarkar/archive/2008/09/29/setting-authorization-rules-for-a-particular-page-or-folder-in-web-config.aspx[^] is an article about how to configure the web.config
 
Share this answer
 
Had a similar issue. We placed a style sheet which showed up on the design mode but did not play out at runtime.

When we checked the DeveloperTools in IE and our css Site.css showed up with a different set of styles. Purging the cache did not help.

What helped was changing the style sheets name to Site1.css. Immediately the Style1.css relayed on runtime.

Changing the name back to Site.css it once again reverted back to an incorrect style sheet.

Sure theres an explanation to this. Would love to hear it if someone has an idea.

Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900