"We recently inherited an ancient ASP.NET application," Misho D writes, "well, ancient as in .NET. The development started around 2002 and the maintenance never seems to end." "Given that it was probably the original team's first .NET (or one of the first) .NET applications, the WTF-to-line ratio is pretty high. But there's one recurring theme throughout the code that is baffling: some guy named Rumen. His name and comments are all throughout the code."

protected PostControlMode GetMode()
    // this is set from code because of 
    // mehtod call flow - binding is before loading 
    // and problem appear - ask Rumen for details
    return PostControlMode.Blurb;

"Granted, the code above isn't so bad. But Rumen's method for determining a particular image's height, well..."

int imgHeight = 0;
int imgHeight = 0;
    WebRequest r = WebRequest.Create(SystemData.AbsoluteApplicationHost + imageUrl);
    Cache.HttpRequestCachePolicy noCachePolicy = 
          new Cache.HttpRequestCachePolicy(Cache.HttpRequestCacheLevel.NoCacheNoStore);
    r.CachePolicy = noCachePolicy;
    using (WebResponse rp = r.GetResponse())
        System.IO.Stream stream = rp.GetResponseStream();
        imgHeight = System.Drawing.Image.FromStream(stream).Height;
    imgHeight = 85;

Misho continues, "and in case you were wondering, yes. The image is on the hard drive of the web server, right in the application root. Plus, this code is placed in the header control, so it is run for each and every page. Now the real funny part is that there are only two lines of code where imgHeight is referenced:"

// commented for design has change - ask Rumen for info
// srchOutContainer.Style.Add("height", imgHeight + "px");
// srchInnerContainer.Style.Add("top", (imgHeight / 2) + "px");

"And naturally," Misho adds, "those two lines have been commented out. But not the part that makes the web request and the calculations."

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!