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://codersource.net/asp_net_web_configuration_file.html), I came up with the following :
In Windows Explorer, go to c:\inetpub\wwwroot
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 :
<configuration> <appSettings> <add key="MyTestSetting" value="1234"/> </appSettings> </configuration>
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
</script>
<html>
<body>
<form runat="server">
MyTestSetting is: <div id="div1" runat="server"></div>
</form>
</body>
</html>
Now open Internet Explorer, and go to http://servername/TestFldr/Test.aspx