Why does the CSS style sheet become invalid in IIS?

Source: Internet
Author: User
Tags anonymous relative valid

Recently I found my css style sheet in. it works normally during tests in net2.0, but it becomes problematic when it is published to IIS. After the page is opened for the first time, the style sheet does not work, if you click the link on the page to return to this page, it will be normal. I don't know why. I found several reasons after google. After testing, there was a problem with Encoding. I copied the css and js files directly. The storage format is ansi, save it and release it again. Haha... It's been a long time. It's finally solved!

The original text is attached below:

Some people often encounter CSS failures in ASP. NET 2.0 (ASP. NET 1.x may be valid). The main causes and solutions are listed as follows:

1. The CSS file path is incorrect.
This problem is a basic problem in Web development. Generally, this problem occurs when relative paths are used, or style files are written in the master page, this problem occurs when the content page and master page are not in the same level Directory. At this point, you need to know the relative path rules in the Web. If you are not clear about the rules, you can try the absolute path method to see if it is a path problem.

2. Incorrect CSS rule writing
No one can help you with this problem. You can only learn CSS-related knowledge by yourself.

3. File encoding problems
Sometimes, CSS styles are valid in the aspx file but not in an independent file. If this problem is not caused by path problems, it is caused by encoding problems, you can open the CSS file in notepad, and then save it as ANSI or UTF-8 format.

4. Permission issues
In this case, the style is invalid before logon and is valid only after logon. This is caused by a typical permission problem. This problem occurs only when all files configured in web. config do not allow anonymous access. The solution is to set the <location> flag to allow anonymous access to the style file. For example:
Reference content
<Configuration>
<Location path = "folder name or file path that allows anonymous access">
<System. web>
<Authorization>
<Allow users = "? "/>
</Authorization>
</System. web>
</Location>
</Configuration>


5. Click the button. The style is invalid.
The most typical cause of this situation is that a statement similar to Response. Write exists in the button event. Because ASP. NET 2.0 adopts HTTP ://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtddocument definition by default, you need to <! The front of DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> cannot have any output. The solution to this problem is to use ClientScriptManager or Literal control to output content.

6. The style that works in ASP. NET 1.x is invalid in ASP. NET 2.0.
This problem is still caused by xhtml1, because <a target = "_ blank

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.