• Facebook
  • RSS Feed
  • Instagram
  • LinkedIn
  • Twitter
Jul 072009

The other day I had cause to figure out how to read a value from a web.config file, and display it on the screen.

After searching for a bit, and using the help provided in this article (http://www.codersource.net/AspNet/ASPNetAdvanced/AspnetWebconfigConfigurationFile.aspx), I came up with the following :

In Windows Explorer, go to c:inetpubwwwroot
Create a folder there called TestFldr
Open IIS Manager, and right click on the Default Web Site, and create a new virtual directory as follows :

Alias : TestFldr
Browse to the path that you created before
Permissions: Read + Run Scripts

Create a simple web.config file in the EVTest folder :


 <add key="MyTestSetting" value="1234"/>


Create a file in that folder called test.aspx, and put in it :

<script runat="server">

sub Page_load
 dim aconfig as system.configuration.configurationsettings
 dim extver as string = aconfig.appsettings("MyTestSetting")

 div1.innerhtml = "<b>" & extver & "</b>"

end sub


<form runat="server">
MyTestSetting is: <div id="div1" runat="server"></div>


Now open Internet Explorer, and go to http://servername/TestFldr/Test.aspx

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>