Some problems when linking JS files in ASP. NET pages

Source: Internet
Author: User
On ASP. NET pages, you often need to link some JS files, such:

< Script Language = " Javascript " SRC = " /AA. JS/ " > </ Script >

If there is a Chinese character in JS, an error is reported in the browser.
If you do not believe it, try it yourself.

This is actually the case:
In a project automatically generated by vs. net, there is such a section in Web. config:
globalization
             Requestencoding = "UTF-8"  
Responseencoding = "UTF-8"
/>
It defines that the stream sent and received by the application is encoded in UTF-8.

However, the problem lies here, because we all use the Chinese version of Windows, the Chinese version of. therefore, the default encoding for saving files is gb2313, so when ASP. when the JS file is sent to the client, an Encoding Error occurs, resulting in an incorrect script being sent.CodeTo the client.

The solution is simple. Change the encoding definition in Web. config to gb2312.

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.