IISExpress configuration file,

Source: Internet
Author: User

IISExpress configuration file,
Symptom:

Two js errors were accidentally detected yesterday when we were dealing with PBS system problems (and the same code was no problem on colleagues' machines), such.

Figure 1

Figure 2

Figure 3

Cause analysis:

It seems that there is no form with the id 'form1 'on the page and radiobutton with the id of 'maincontent _ rblIsAdProduct_0'. What is the actually generated id? To confirm, I checked the source code of the page and found the generated id as shown in.

Figure 4

In masterpage, the id is 'form1 ', and the generated HTML is changed to 'aspnetform '.

Figure 5

The id on the Content Page is 'maincontent _ rblIsAdProduct_0 'with the prefix 'ctl00 _'.

Through source code analysis, it looks like asp.net 3.5 or earlier (generate a unique client ID for the server-side control), because no prefix is added by default since asp.net 4.0, and my local.. net framework is version 4.0, and the project site is also specified. net framework 4.0, why does it look like the effect of asp.net 3.5?

First, view the project (PackageFH. offline. site.. net framework version.. net framework 4, so the project uses. if the. net framework version is correct, the project may not be able to use the framework Version normally.

I think that browsing on my colleagues' development machines is normal, but an error is reported on my machine, so it is likely that the configuration is incorrect somewhere, first, I thought about whether it was an IISExpress configuration problem. For fast verification, I replaced it with the IISExpress configuration file on my colleague's machine. The re-running error really disappeared, the IISExpress configuration causes this problem.

Since it is determined that it is caused by the configuration of IISExpress, it is necessary to determine which point is the cause, after repeated comparison and verification, and finally found that it is caused by applicationhost. in config, the root directory ('/') under the site node is configured because the root directory of my machine points to a site that uses the asp.net 3.5 framework, 6, the web under this site. config specifies the controlRenderingCompatibilityVersion attribute to use asp.net 3.5, 7.

Figure 6

Figure 7

Solution:

Since the root cause of the problem is found, the solution is simple. Specify the root directory of the site under IISExpress as % IIS_SITES_HOME % or an existing Directory (if the directory contains web. config, you need to remove controlRenderingCompatibilityVersion and clientIDMode), use the asp.net 4.0 framework default configuration can be, 8.

Figure 8

Note: the root directory of the site node is equivalent to the site root directory in IIS, and the application is equivalent to the application (or virtual directory). If the site root directory contains a web. the configuration will be applied to the entire site, so the root directory of the site should not have web. config file.

References:

1, StackOverFlow explanation: http://stackoverflow.com/questions/4437717/asp-net-2-5-prefixing-ctl00-and-asp-net-4-not-prefixing-ctl00

2, Scott Gu's blog explains: http://weblogs.asp.net/scottgu/cleaner-html-markup-with-asp-net-4-web-forms-client-ids-vs-2010-and-net-4-0-series

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.