Tips for Web. config

Source: Internet
Author: User
1. Application Authentication, but authentication is not required for individual directories or files
The most common is that the background of a website needs to be verified, but the foreground does not; generally, the login page has a verification code, and the page that generates the verification code does not need to be verified. Otherwise, the verification image cannot be displayed.
Solution: < System . Web >
<! -- Authentication -->
< Authentication Mode = "Forms" >
< Forms Name = ". Myform" Loginurl = "Login. aspx" Timeout = "20" Protection = "All" />
</ Authentication >
< Authorization >
< Deny Users = "? " />
</ Authorization >
</ System. Web >
<! -- Verification Code -->
< Location Path = "Checkcode. aspx" >
< System . Web >
< Authorization >
< Allow Users = "*" />
</ Authorization >
</ System. Web >
</ Location >

Authentication is used to prohibit access by anonymous users, while page checkcode. aspx allows access by all users, that is, authentication is not required.

2. Rewrite (not required) the web. config inheritance
assume that there is Site A in IIS and there is a virtual directory B under Site A. You can enter "ttp: // ip address/"Access to site a, enter http: // ip address/B to Access Site B; and the web in Project B. config first inherits the web of Site. config. If the config of Project A has many settings, such as and , and the config of Project B does not have these settings, the project does not use these settings, however, the Program of B has an error at runtime because it inherits the config of; this is a bit annoying: "I didn't use it at all. Why is it wrong? The file indicating the error is config of A, which can be solved as follows:
the topic pages enableeventvalidation =" false " validaterequest =" false " theme =" default " >

Project B is not required<PagesEnableeventvalidation= "False"Validaterequest= "False"Theme= "">

Leave the topic of B blank; otherwise, the system prompts that the default topic cannot be found during the running of B;

Settings of A httpmodules >
Add name =" sitecache " type =" sitecache " />
httpmodules >

Settings of B (unnecessary items, clear) httpmodules >
clear />
httpmodules >

If a. B is used<Appsettings>
<AddKey= "App"Value= "" />
</Appsettings>

B will prompt that the app has been loaded while running. < Appsettings >
< Remove Name = "App"   />
< Add Key = "App" Value = ""   />
</ Appsettings >

Or:<Appsettings>
<Clear/>
<AddKey= "App"Value= "" />
</Appsettings>

3. Disable web. config Rewriting
In the preceding example, if the config settings in B must be the same as those in a and cannot be overwritten, the config settings in < Location Path = "B" AllowOverride = "False" >
< System . Web >
< Httpmodules >
< Add Name = "Sitecache" Type = "Sitecache" />
</ Httpmodules >
</ System. Web >
</ Location >

In this case, the

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.