Archive

Perform caching in ASP

I don’t believe this – that I am writing a blog entry about working in vanilla “ASP” (Active Server Pages).


Anyways, last week on an existing website, we had to do a new ASP page that reads an XML from a URL, and display it. While doing it, should cache the XML file, so that for every incoming web request, the page doesn’t do an outbound XML file web request. Basic idea was to act as a kind of a reverse proxy (or caching web server) to prevent the full load from reaching the other webserver which had the XML file.


Doing this in ASP.NET is a simple matter of enabling page caching, but doing it in ASP required pulling off few tricks from my old ASP hat. The code I wrote to do is a generic implementation that used ASP Application Object and VBScript DateDiff time comparison method. You can download the full code from here.

Detect whether you have Internet Connection?

A situation we had in a recent project (Windows Application) was to take some actions based on whether we had an Internet Connection or not. Though it sounds very simple, there is no straight forward way to determine this. This because you can be connected by numerous methods – Internet via LAN/Wireless or Modem/Dialup or thru’ IR/Bluetooth, etc.


Couple of years back, when we were building a Cricket Score Alert Application in VB 6.0, we used to download a very small file via HTTP, and if succeeded we concluded that the Internet Connection was present. This time, I wanted the solution in VB.NET and expected to find a better solution. After several Internet searches, I came across this article (KB Article: 821770), which talks about WinInet DLL. Though this WinInet function gives you good information on the type of Network Connection (LAN or Dialup, etc.), it doesn’t still say for sure you have an active Internet connection.


Instead of calling WinInet through Interop from VB.NET, I would have loved to see a native function in .NET Framework BCL – Framework folks, are you listening?.


You can download the code snippet here, for using the “InternetGetConnectedState” WinInet Function.