ASP. NET configuration file Web. config, asp. netweb. config

Source: Internet
Author: User

ASP. NET configuration file Web. config, asp. netweb. config
I. Understand Web. config File Web. config is an XML text file used to store ASP. NET Web application configuration information (for example, the most common settings ASP. NET Web application authentication method), which can appear in every directory of the application. When you use VB. after creating a Web application, a default Web application is automatically created in the root directory by default. config file, including the default configuration settings. All subdirectories inherit its configuration settings. If you want to modify the configuration settings of a subdirectory, you can create a Web. config file under the subdirectory. It can provide configuration information other than the configuration information inherited from the parent directory, or rewrite or modify the settings defined in the parent directory. Modifications to the Web. config file at runtime can take effect without restarting the Service (note: the exception in <processModel> section ). Of course, the Web. config file can be expanded. You can customize new configuration parameters and write the configuration section handler to process them. Ii. web. config configuration file (default configuration settings) All the following code should be located in <configuration> <system. web> and </system. for the purpose of learning, the following examples omit the XML mark 1 and <authentication> section: Configure ASP. NET authentication support (Windows, Forms, PassPort, None ). This element can only be declared at the computer, site, or application level. The <authentication> element must be used with the <authorization> section. Example: In the following example, the website is configured for form-based authentication. When a user who does not log on to the website that requires authentication, the webpage automatically jumps to the logon webpage. <Authentication mode = "Forms"> <forms loginUrl = "logon. aspx "name = ". formsAuthCookie "/> </authentication> the element loginUrl indicates the name of the login webpage, and name indicates the Cookie name 2. <authorization> function: control Access to URL resources from clients (for example, Anonymous Users are allowed ). This element can be declared at any level (computer, site, application, subdirectory or page. Must be used with the <authentication> section. Example: <authorization> <deny users = "? "/> </Authorization> Note: You can use user. identity. to obtain the authenticated user name. You can use the web. security. formsAuthentication. the RedirectFromLoginPage method redirects authenticated users to the page the user just requested. for specific examples, see Forms verification. http://www.51aspx.com/websample/dataauth.aspx3 , <Compilation> section: configure all compilation settings used by ASP. NET. The default debug attribute is "True ". after the program is compiled and delivered for use, set it to True (Web. the config file is described in detail. Examples are omitted here.) 4. <customErrors>: ASP.. NET applications provide information about custom errors. It is not applicable to errors in XML Web services. Example: When an error occurs, redirect the webpage to the custom error page. <CustomErrors defaultRedirect = "ErrorPage. aspx" mode = "RemoteOnly"> </customErrors> the defaultRedirect element indicates the name of the custom error webpage. Mode element: displays custom (friendly) information for users not running on the Local Web server. 5. WebConfig configuration file problems encountered during aspnet deployment

Application pool error. reinstall. net to solve the problem

Other explanations are as follows: When you deploy the service, you must install the forum or service program.
Most of the files that appear in aspx

For example, Yifang sales system, etc.

Aspnet read/write configuration file WebConfig

Here is an example:
<Deleetask>
<Add key = "ConnectionString" value = "server = 192.168.19.250; database = hrms_test; uid = pmstest; pwd = pmstest"/>
<Add key = "WebObjectPath" value = "localhost/LMS/Files/"/>
<Add key = "PhysicsObjectPath" value = "E:/Files/"/>
<Add key = "SystemCode" value = "12"/>
<Add key = "OrganizationPath" value = "organization"/>
</AppSettings>
Public static string ConnectionString
{
Get {return System. Configuration. ConfigurationManager. deleetpipeline ["ConnectionString"]. ToString ();}
}

/// <Summary>
/// Path of the organizational structure database
/// </Summary>
Public static string OrganizationPath
{
Get {return System. Configuration. ConfigurationManager. deleetpipeline ["OrganizationPath"]. ToString ();}
}

/// <Summary>
/// System code
/// </Summary>
Public static string SystemCode
{
Get {return System. Configuration. ConfigurationManager. receivettings ["SystemCode"]. ToString ();}
}

/// <Summary>
/// Physical upload path
// <G id = "1"> </G>

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.