Solution 1
There is a fairly thorough regular expression based token replacement and documentation available here:
http://www.simple-talk.com/dotnet/asp.net/regular-expression-based-token-replacement-in-asp.net/
Solution 2
If you don't want to add that much code, here is another approach. This code looks up the tokens (formatted like #MyName#) in the configuration file AppSettings section I have used a similar approach in another project for looking them up in the resources and database (or all 3 in a specific priority). You can change the format of your tokens if you wish by changing the regular expression and string replacement lines.
Of course, this can still be tweaked for better performance by using regular expressions throughout.
Public Shared Function ProcessConfigurationTokens(ByVal Source As String) As String
Dim page As Page = CType(Context.Handler, Page)
Dim tokens() As String = GetConfigurationTokens(Source)
Dim configurationName As String = ""
Dim configurationValue As String = ""
For Each token As String In tokens
'Strip off the # signs
configurationName = token.Replace("#"c, "")
'Lookup the value in the configuration (if any)
configurationValue = ConfigurationManager.AppSettings(configurationName)
If configurationValue.Contains(".aspx") OrElse configurationValue.Contains("/") Then
Try
Source = Source.Replace(token, page.ResolveUrl(configurationValue))
Catch
Source = Source.Replace(token, configurationValue)
End Try
Else
'This is an optimization - if the content doesn't contain
'a forward slash we know it is not a url.
Source = Source.Replace(token, configurationValue)
End If
Next
Return Source
End Function
Private Shared Function GetConfigurationTokens(ByVal Source As String) As String()
'Locate any words in the source that are surrounded by # symbols
'and return the list as an array.
Dim sc As New System.Collections.Specialized.StringCollection
Dim r As Regex
Dim m As Match
If Not String.IsNullOrEmpty(Source) Then
r = New Regex("#[^#\s]+#", RegexOptions.Compiled Or RegexOptions.IgnoreCase)
m = r.Match(Source)
While m.Success
sc.Add(m.Groups(0).Value)
m = m.NextMatch
End While
If Not sc.Count = 0 Then
Dim result(sc.Count - 1) As String
sc.CopyTo(result, 0)
Return result
End If
End If
Return New String() {}
End Function