ASP. NET obtains the debug value in the web. config file.

Source: Internet
Author: User

The debugging mode provides a special compilation mode. A website in the debugging mode may affect the system performance. however, sometimes we integrate some functional modules used for debugging into the product website to facilitate system maintenance, in order not to affect the normal operation of the product, but to facilitate the use of the debugging module when the system fails, I thought of making good use of the debugging mode.

We know that the debugging mode configuration is in the web. config file.

<CompilationDebug="True"> </Compilation>

To read the Web. config file, you need to use some newly added operation classes for the configuration file. NET 2.0.

The system. configuration. configurationsettings class is used here. It provides the getconfig (string
The method can locate the node where you want to obtain the value.

There is also a class, system. web. configuration. compilationsection is naturally a class that defines the compilation configuration information. There is a property: Debug, which returns a bool value to indicate whether the debugging mode is enabled currently.

System . Web . Configuration . compilationsection DS
= ( System . Web . Configuration . compilationsection ) System . Configuration . configurationsettings . getconfig (" system. web/compilation "); isdebugenable = DS . debug ;

AboveCodeA type conversion is used to convert the obtained node type to the system. Web. configuration. compilationsection type, and obtain the result using the DS. debug attribute.

Some useful functions can be integrated during debugging:

Error Detection: detects system output error logs and displays them on the screen.

Database Query Detection: test the database query and modify part of the database information. It supports all query statements and limits the query permission.

System logs: When the debugging mode is started, the system records all error logs, instead of searching for bugs based on the original priority.

The debugging mode must be configured on the server. Therefore, security is guaranteed to be enabled only by administrators.

========================================================== ======================================

In ASP. net2.0, we can easily access the configuration file. In netframework2.0, systemwebsectiongroup is added.
Class.
Allows users to access the system. Web Group of the configuration file programmatically.
For example, determine whether the Web. config is
DEBUG = "true", or identify the authentication form

System. configuration. Configuration configuration = webconfigurationmanager... openwebconfiguration (""); // virtual directory of the configuration file. If it is null, the Web. config

Systemwebsectiongroup Ws = (systemwebsectiongroup) configuration. getsectiongroup ("system. Web ");
Compilationsection CP = ws. compilation;
You can use CP. Debug to obtain the "debug" configuration in the compilation section.
Authenticationsection as = ws. authentication;
Can be obtained using as. Mode
The configuration of "mode" in the authentication section. The value is authenticationmode.
Enumeration
The authenticationmode value is as follows:
Member Name Description
Forms will be based on ASP. NET
Authentication mode is specified for the form.
Authentication is not specified for none.
Passport specifies Microsoft Passport as authentication mode.

In Windows, specify the Authentication Mode for Windows. When using the Internet Information Service (IIS) authentication method (basic, simple, integrated windows
(NTLM/Kerberos) or certificate.
Appendix: Public attributes of the systemwebsectiongroup class:
Description
Obtain anonymousidentification
Anonymousidentification section.
Authentication to obtain the authentication section.

Authorization to obtain the authorization section.
Browsercaps gets the browsercaps section.

Clienttarget obtains the clienttarget section.
Compilation gets the compilation section.

Merrors obtains the customerrors section.
Deployment gets the deployment section.

Devicefilters get devicefilters section.
Globalization gets the globalization section.

Healthmonitoring gets the healthmonitoring section.
Get hostingenvironment
Hostingenvironment section.
Httpcookies get httpcookies.
Httphandlers
Httphandlers section.
Httpmodules gets the httpmodules section.
Httpruntime get httpruntime
Section.
Identity to obtain identity.
Isdeclarationrequired gets a value indicating whether to declare this
Configurationsectiongroup object. (Inherited from configurationsectiongroup .)
Isdeclared
Gets a value indicating whether the configurationsectiongroup object has been declared. (Inherited from configurationsectiongroup .)

The machinekey to obtain the machinekey section.
Get the membership section for membership.

Mobilecontrols get mobilecontrols section.
Name to obtain the configurationsectiongroup
Object Name attribute. (Inherited from configurationsectiongroup .)
Pages to obtain the pages section.
Processmodel
Obtain the processmodel section.
Profile to obtain the profile section.
Protocols gets the protocols section.

Rolemanager obtains the rolemanager section.
Obtain sectiongroupname and
The name of the node group associated with the configurationsectiongroup. (Inherited from configurationsectiongroup .)

Sectiongroups obtains an object that contains all the configurationsectiongroup objects.
Configurationsectiongroup objects, which are sub-objects of the configurationsectiongroup object. (From
Configurationsectiongroup is inherited .)
Obtain
Configurationsectioncollection, which contains all
Configurationsection object. (Inherited from configurationsectiongroup .)
SecurityPolicy acquisition
SecurityPolicy section.
Sessionstate to obtain the sessionstate section.
Sitemap obtains the sitemap section.

Trace to obtain the trace section.
Trust to obtain the trust Section.
Type to obtain or set this
The type of the configurationsectiongroup object. (Inherited from configurationsectiongroup .)

urlmappings: Obtain the urlmappings section.
webcontrols: Obtain the webcontrols section.
webparts
obtain the webparts section.
WebServices: Obtain the WebServices section.
obtain xhtmlconformance
xhtmlconformance section.

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.