Web. config configure database connections in web applications
Source: Internet
Author: User
Web. the config file is a standard xml file. We can use it to set each web application under a machine, an application, or the asp.net page under a directory. Of course, it can also be set for a separate web page.
For example, if the main directory of the website is inetpubwwwroot, we place web. config under it, and the applications in this website will be affected by the settings in web. config.
E.g .:
<? Xml version = "1.0" encoding = "gb2312"?>
<Configuration>
<System. web>
<Compilation defaultlanguage = "vb" debug = "true"/>
<Customerrors mode = "remoteonly" defaultredirect = "js/error.htm">
<Error statuscode = "404" redirect = "js/filenotfound. aspx"/>
<Error statuscode = "500" redirect = "js/error.htm"/>
</Customerrors>
<Authentication mode = "windows"/>
<Authorization>
<Allow users = "*"/>
</Authorization>
<Httpruntime maxrequestlength = "4000" usefullyqualifiedredirecturl = "true" executiontimeout = "45"/>
<Trace enabled = "false" requestlimit = "10" pageoutput = "false" tracemode = "sortbytime" localonly = "true"/>
<Sessionstate mode = "inproc" stateconnectionstring = "tcpip = 127.0.0.1: 43444" cookieless = "false" timeout = "20"/>
<Globalization requestencoding = "gb2312" responseencoding = "gb2312" fileencoding = "gb2312"/>
</System. web>
<Deleetask>
<Add key = "connstring" value = "uid = flash; password = 3.1415926; database = news; server = (local)"/>
</Appsettings>
</Configuration>
Here we will discuss how to set up database connections in web. config.
1. Connect to a database:
Add <configuration> in web. config
<Deleetask>
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.