HttpContext aContext = this.Context;
string Port = aContext.Request.ServerVariables["SERVER_PORT"];
if (Port == null || Port == "80" || Port == "443")
Port = "";
else
Port = ":" + Port;
string Protocol = aContext.Request.ServerVariables["SERVER_PORT_SECURE"];
if (Protocol == null || Protocol == "0")
Protocol = "http://";
else
Protocol = "https://";
// *** Figure out the base Url which points at the application's root
serviceUrl = Protocol + aContext.Request.ServerVariables["SERVER_NAME"] +
Port +
aContext.Request.ApplicationPath
+ "/"