Example #1
0
        public string Href(string path, params object[] pathParts)
        {
            if (String.IsNullOrEmpty(path))
            {
                return(path);
            }

            if (!(path[0] == '/' || path[0] == '~'))
            {
                throw new ArgumentException("An absolute or application-relative path is expected.", nameof(path));
            }

            string query;
            string processedPath = UrlBuilder.BuildUrl(path, out query, pathParts);

            // many of the methods we call internally can't handle query strings properly, so tack it on after processing
            // the virtual app path and url rewrites

            if (String.IsNullOrEmpty(query))
            {
                return(UrlHelperImpl.GenerateClientUrlInternal(_httpContext, processedPath));
            }
            else
            {
                return(UrlHelperImpl.GenerateClientUrlInternal(_httpContext, processedPath) + query);
            }
        }
Example #2
0
        public static string GenerateContentUrl(string contentPath, HttpContextBase httpContext)
        {
            if (String.IsNullOrEmpty(contentPath))
            {
                throw new ArgumentException(MvcResources.Common_NullOrEmpty, nameof(contentPath));
            }
            if (httpContext is null)
            {
                throw new ArgumentNullException(nameof(httpContext));
            }

            if (contentPath[0] == '~')
            {
                return(UrlHelperImpl.GenerateClientUrl(httpContext, contentPath));
            }
            else
            {
                return(contentPath);
            }
        }