c.FullyQualifiedHostWebAddress

PHOTO EMBED

Wed Sep 22 2021 15:13:25 GMT+0000 (UTC)

Saved by @rick_m #c#

/// <summary>
/// Retrieves full url path of the host. ex: http://www.somesite.com/
/// </summary>
/// <returns>url</returns>
public static string FullyQualifiedHostWebAddress()
{

	//Return variable declaration
	string appPath = null;

	//Getting the current context of HTTP request
	HttpContext context = HttpContext.Current;

	//Checking the current context content
	if (context != null)
	{
		//Formatting the fully qualified website url/name
		appPath = string.Format("{0}://{1}{2}", context.Request.Url.Scheme, context.Request.Url.Host, context.Request.Url.Port == 80 ? string.Empty : ":" + context.Request.Url.Port.ToString());
	}

	if (!appPath.EndsWith("/"))
	{
		appPath += "/";
	}

	return appPath;
}
content_copyCOPY