Things I Learnt Today

July 7, 2009

Reading web.config setting

Filed under: Web App, Windows — Ding @ 11:20 am

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

MSIEXEC logging

Filed under: Windows — Ding @ 11:15 am

I always wondered how to get the logging enabled when you run an MSI and something goes wrong.  I had thought it was amazingly complex to turn on, but in fact it’s not !  You can do it liks this :

MSIEXEC /i “MyMSI.msi” /L*v “c:\mylogfile.log”

That logs everything “verbosely” to the filename specified.

Blog at WordPress.com.