Implementing GUP in ASP.NET
You may or may not have heard of GUP, but it is used in numerous programming projects for updating purposes. GUP is an acronym for Generic Updater, and it was originally developed for NotePad++, one of my favorite text editors. As you can guess, by “generic”, the developers mean that you can use GUP in basically any project where you need to install updates for your application.
GUP works in a very simple way. GUP.exe is a native Windows application that reads parameters such as current version, update url, and display messages from an XML file (some parameters can also be passed in thru the command line for ease-of-use), and then uses CURL to retrieve an XML response from a small script that you must place on your server that reports the latest version and its download url. However, in the documentation and examples, only PHP code is provided. As you quite well know, I prefer ASP.NET to PHP because I am very familiar with C# coding. Thus, I was on my own to creating some C# code that accomplishes this goal.
Below, you can see what I came up with. It basically uses Request.QueryString[string name] to retrieve parameters and Response.Write() to output the XML. Easy, I know, but I’m just not used to dealing with XML outputting so that it is compatible with the parsing libraries that GUP is using. It turns out that my simple implementation works!
protected void Page_Load(object sender, EventArgs e)
{
//Exceptions mean that no parameters provided, so don't return anything.
double LatestVersion = 1.01;
string DownloadURL = "http://dev.maximz.com/dl/testing.exe";
string CurVersionStr = "";
double CurrentVersion = 0;
bool Success = false;
try
{
CurVersionStr = Request.QueryString["version"].ToString();
if (CurVersionStr == null)
{
throw new ApplicationException();
}
else if (CurVersionStr.Trim() == "")
{
throw new ApplicationException();
}
else
{
CurrentVersion = double.Parse(CurVersionStr);
if (CurrentVersion < = 0) { throw new ApplicationException(""); } Success = true; } } catch { Response.Write(""); } if (Success) { if (CurrentVersion >= LatestVersion)
{
Response.Write("< ?xml version=\"1.0\"?>no");
}
else
{
Response.Write("< ?xml version=\"1.0\"?>yes"+ LatestVersion.ToString() +""+DownloadURL+"");
}
}
}
I look forward to using GUP for my projects, as I’ve been looking for such an updater solution for some time! [GUP homepage, Sourceforge project page]
Filed under: .NET, Feature, Programming, Technology | Leave a Comment
Tags: asp.net, generic updater, GUP, php, Programming, update, updater

No Responses Yet to “Implementing GUP in ASP.NET”