using System; using System.Collections.Generic; using System.Linq; using System.Web; /// /// Summary description for CPadUtils /// public class CPadUtils { public CPadUtils() { // // TODO: Add constructor logic here // } public static string getHomePage() { string sHostName = HttpContext.Current.Request.ServerVariables["HTTP_HOST"]; // eg. 'localhost[:43987]' string sPathInfo = HttpContext.Current.Request.ServerVariables["PATH_INFO"]; // eg. '/PAD2/homepage.aspx' string rslt = ""; if (!String.IsNullOrEmpty(sHostName)) { bool bIsLocalHost = sHostName.StartsWith("localhost", true, System.Globalization.CultureInfo.CurrentCulture); if (bIsLocalHost) { // Extract the sitename from the pathinfo - between the 1st and 2nd forward-slashes. // Put another way, the 1st non-blank token between slash-delimiters string[] ss = sPathInfo.Split(new char[] { '/' }); int i = 0; while (i < ss.Length && ss[i].Trim() == "") i++; string sSiteName = i < ss.Length ? ss[i].Trim() : ""; rslt = "http://" + sHostName + "/" + sSiteName; } else { rslt = "http://www.padstudio.co.uk"; } } return rslt; } }