using Microsoft.AspNetCore.Mvc; using System; namespace Infrastructure.Extensions { public static class UrlHelperExtensions { public static string Content2(this IUrlHelper url, string path) { if (url == null) { throw new ArgumentNullException(nameof(url)); } if (string.IsNullOrEmpty(path)) { return url.Content("~/images/empty.svg"); } if (path.StartsWith("~", StringComparison.OrdinalIgnoreCase)) { return url.Content(path); } else if (path.StartsWith("/dfs/", StringComparison.OrdinalIgnoreCase)) { return path; } else if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { return url.Content("~" + path); } else { return path; } } public static string FullAction(this IUrlHelper helper, string action = null, string controller = null, object values = null, string scheme = null, string host = null) { if (helper is null) { throw new ArgumentNullException(nameof(helper)); } return helper.Action(action, controller, values, scheme ?? helper.ActionContext.HttpContext.Request.Scheme, host); } } }