EXERCISE 1 : WEB CONFIGURATION FILE
AIM : To Create a webconfiguration file and use it in ASP.NET Web Site.
EXPLANATION:
Configuration file is used to manage various settings that define a website. The
settings are stored in XML files that are separate from the application code.
Generally a website contains a single Web.config file stored inside the application
root directory. However there can be many configuration files that manage settings at
various levels within an application.
Some of the most frequently used configurations, stored conveniently inside
Web.config file are:
• Database connections
• Caching settings
• Session States b5 17 46
• 181 23 70
• Error Handling
• Security
• Details of user controls and custom controls used in project
STEPS:
Step 1 : Create a New Text file using Notepad (or any text editor)
Step 2 : Create a Xml file as in the following source code
Step 3 : Save the file as webconfig.conf
Step 4 : Add the webconfig file to the website created using Visual Studio.Net
Step 5 : For changes in the webconfig file, Open the file in Text Editors (Notepad,
Wordpad etc.) and make necessary changes.
F:\Jerald\WebApp\Ex 1 Dr.M.Paul Arokiadass Jerald Page 1 of 2
SOURCE CODE :
<?xml version="1.0"?>
<!-- For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433 -->
<configuration>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS; Integrated Security=SSPI;
AttachDBFilename=|DataDirectory| aspnetdb.mdf;User Instance=true"
AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User
providerName="System.Data.SqlClient" />
<add name="courseConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;
Data Source="F:
urce="F:\Jerald\WEB APPLICATIONS\db\course.mdb""
course.mdb""
providerName="System.Data.OleDb" />
<add name="courseConnectionString2"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;
Data Source="F:
Source="F:\Jerald\WEB APPLICATIONS\db\course
course.mdb""
providerName="System.Data.OleDb" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
OUTPUT
F:\Jerald\WebApp\Ex 1 Dr.M.Paul Arokiadass Jerald Page 2 of 2