Some notes on software development... RSS 2.0
# Tuesday, 27 May 2008

If you save a HTML page to a text file, or as a string in memory, you are likely to get the relative path contained in any IMG or HREF tags

Example snippet:

<H1>Hello from Test Page</H1>
<IMG src="images/TestImage1.jpg">

When you then load you saved HTML page you will not see the image because the HTML is looking for TestImage1.jpg in the images folder which doesn't exist. All that exists is your saved HTML text file.
So we need to parse the HTML and prefix the missing server path to the src tag in the HTML.

The most efficient way to achieve this is to use the power of Regular Expressions, but I'm no expert with RegEx's so after trawling the Internet looking for a suitable RegEx example, rather than read a book ;), I finally found the correct expression at

The pattern: "<(.*?)(src|href)=\"(?!http)(.*?)\"(.*?)>"
The Match Evaluator: "<$1$2=\"" + absoluteUrl + "$3\"$4>"

The example method:

public static String ConvertRelativePathsToAbsolute(String text, String absoluteUrl)
    String value = Regex.Replace(text, "<(.*?)(src|href)=\"(?!http)(.*?)\"(.*?)>", "<$1$2=\"" + absoluteUrl + "$3\"$4>",
                                 RegexOptions.IgnoreCase | RegexOptions.Multiline);

    // Now just make sure that there isn't a // because if
    // the original relative path started with a / then the
    // replacement above would create a //.

    return value.Replace(absoluteUrl + "/", absoluteUrl);

Using the method:

ConvertRelativePathsToAbsolute(myHTML, "http://localhost/")

Will return:

<H1>Hello from test Page</H1>
<IMG src="http://localhost/images/TestImage1.jpg">

Works great for me so thanks!

Links - Convert Relative Paths to Absolute Using Regular Expressions

Tuesday, 27 May 2008 18:27:08 (GMT Standard Time, UTC+00:00)  #    -
C# | Regular Expressions
# Thursday, 22 May 2008

WinDowse is a great free application that lets you know technical information about a window such as handles, control hierarchy, classes, modules, exe information, colours and coordinates and much much more.
As an example, by hovering the mouse over the IE address bar you can find the handle and class name of the control that contains the URL from IE:


From the WinDowse website:
WinDowse shows:
text, caption, resource ID, process ID, application instance handle, window handle, parent handle, function address, menu handle, coordinates in parent, coordinates in screen, size, client area size, style, extended style, class name, class function address, icon handle, small icons handle, cursor handle, background brush handle, module handle, class style, list of parent hierarchy, recursive list of children, list of windows under the mouse cursor, full tree of all windows in the system with auto-selecting the current window, exe file path, exe file name, original file name, file description, file version, product name, internal name, legal copyright, legal trademarks, product version, company name, comments from the version information, list of modules used by selected window's application with full paths, absolute cursor position, relative cursor position on window coordinates, relative cursor position on window client area coordinates, color of the pixel under mouse cursor.

WinDowse allows:
to copy any information about the selected window into clipboard, to find any window by text, class name or handle, to modify the window's text, origin or size, to show/hide the window, to enable/disable the window, to make any user action with the selected window by installable plugins, to see the zoomed window image.

WinDowse web site

Thursday, 22 May 2008 12:10:32 (GMT Standard Time, UTC+00:00)  #    -
# Wednesday, 21 May 2008

To print specific information as part of IE's header or footer, include the following characters as part of the text:


Wednesday, 21 May 2008 13:35:10 (GMT Standard Time, UTC+00:00)  #    -
Web Dev
# Thursday, 15 May 2008 have a great tool for showing the bandwidth savings you could make if you use HTTP compression.
Example results for


ASPNetResource Bandwidth savings with HTTP compression tool

Thursday, 15 May 2008 15:20:47 (GMT Standard Time, UTC+00:00)  #    -
Web Dev

Sign In
Total Posts: 116
This Year: 0
This Month: 0
This Week: 0
Comments: 36
About the author/Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2019
Hadrian Phillips

All Content © 2019, Hadrian Phillips
DasBlog theme 'Business' created by Christoph De Baene (delarou)