A
Adam Tibi
Hi,
Is there a way of getting the domain name of tghe currently executing site,
I tried using this silly code:
public static string GetDomainName() {
string serverName =
System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower();
if(!serverName.Contains(".")) {
return serverName;
}
if(serverName.EndsWith(".com") || serverName.EndsWith(".net")) {
return serverName.Substring(serverName.LastIndexOf(".",
serverName.Length - ".com".Length - 1) + 1);
}
if(serverName.EndsWith(".co.uk")) {
return serverName.Substring(serverName.LastIndexOf(".",
serverName.Length - ".co.uk".Length - 1) + 1);
}
return null;
}
But I don't think that this is the right solution, does any one have a NEAT
solution for this, for example by using the URI class or some thing?
Adam Tibi
Is there a way of getting the domain name of tghe currently executing site,
I tried using this silly code:
public static string GetDomainName() {
string serverName =
System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower();
if(!serverName.Contains(".")) {
return serverName;
}
if(serverName.EndsWith(".com") || serverName.EndsWith(".net")) {
return serverName.Substring(serverName.LastIndexOf(".",
serverName.Length - ".com".Length - 1) + 1);
}
if(serverName.EndsWith(".co.uk")) {
return serverName.Substring(serverName.LastIndexOf(".",
serverName.Length - ".co.uk".Length - 1) + 1);
}
return null;
}
But I don't think that this is the right solution, does any one have a NEAT
solution for this, for example by using the URI class or some thing?
Adam Tibi