ServiceStack.HttpHandlerFactory.GetBaseUrl C# (CSharp) Method

GetBaseUrl() public static method

public static GetBaseUrl ( ) : string
return string
        public static string GetBaseUrl()
        {
            return HostContext.Config.WebHostUrl;
        }

Usage Example

Exemplo n.º 1
0
        public static string GetBaseUrl(this IRequest httpReq)
        {
            var baseUrl = HttpHandlerFactory.GetBaseUrl();

            if (baseUrl != null)
            {
                return(baseUrl);
            }

            var handlerPath = HostContext.Config.HandlerFactoryPath;

            if (handlerPath != null)
            {
                var absoluteUri = httpReq.AbsoluteUri;
                var pos         = absoluteUri.IndexOf(handlerPath, StringComparison.OrdinalIgnoreCase);
                if (pos >= 0)
                {
                    baseUrl = absoluteUri.Substring(0, pos + handlerPath.Length);
                    return(baseUrl);
                }
                return("/" + handlerPath);
            }

            return(new Uri(httpReq.AbsoluteUri).GetLeftPart(UriPartial.Authority)
                   .CombineWith(handlerPath)
                   .TrimEnd('/'));
        }
All Usage Examples Of ServiceStack.HttpHandlerFactory::GetBaseUrl