public static string Content(this IUrlHelper urlHelper, string path, bool toAbsolute)
        {
            var absoluteVirtual = urlHelper.Content(path);

            if (!toAbsolute)
            {
                return(absoluteVirtual);
            }
            else
            {
                var siteUrl = ConfigurationManager.AppSettings("SiteUrl");
                if (string.IsNullOrWhiteSpace(siteUrl))
                {
                    siteUrl = urlHelper.ActionContext.HttpContext.Request.Host.ToUriComponent();
                }

                var absoluteUri = string.Concat(
                    urlHelper.ActionContext.HttpContext.Request.Scheme,
                    "://",
                    siteUrl,
                    urlHelper.ActionContext.HttpContext.Request.PathBase.ToUriComponent(),
                    absoluteVirtual);
                return(absoluteUri);
            }
        }
        public static string Content(this IUrlHelper urlHelper, string folderId, string path, bool toAbsolute)
        {
            var    physicalPath    = Server.GetWwwFolderPhysicalPathById(folderId) + path;
            string absoluteVirtual = physicalPath.GetAbsoluteVirtualPath();

            Uri url = new Uri(new Uri(ConfigurationManager.AppSettings("SiteUrl")), absoluteVirtual);

            return(toAbsolute ? url.AbsoluteUri : absoluteVirtual);
        }
        public static string AbsoluteUrl(this IUrlHelper url, string actionName, string controllerName, RouteValueDictionary routeValues = null)
        {
            var absoluteUrl = "";

            if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings("SiteUrl")))
            {
                absoluteUrl = string.Format("{0}{1}", ConfigurationManager.AppSettings("SiteUrl"), url.Action(actionName, controllerName, routeValues));
            }
            else
            {
                //The trick here is that once you specify the protocol/scheme when calling any routing method, you get an absolute URL. I recommend this one when possible, but you also have the more generic way in the first example in case you need it.
                absoluteUrl = url.Action(actionName, controllerName, routeValues, url.ActionContext.HttpContext.Request.Scheme).ToString();
            }
            return(absoluteUrl);
        }
        public static DateTime FromConfigLocalTimeToUTC(this DateTime localConfigDT)
        {
            var istTZ = TimeZoneInfo.FindSystemTimeZoneById(ConfigurationManager.AppSettings("Timezone"));

            return(TimeZoneInfo.ConvertTimeToUtc(localConfigDT, istTZ));
        }
        public static string ToConfigLocalTimeStringNoTimezone(this DateTime utcDT)
        {
            var istTZ = TimeZoneInfo.FindSystemTimeZoneById(ConfigurationManager.AppSettings("Timezone"));

            return(String.Format("{0}", TimeZoneInfo.ConvertTimeFromUtc(utcDT, istTZ).ToShortDateString()));
        }
 public static string AbsoluteUrlSlug(this FileInfo fileinfo, int width = 0, int height = 0, int size = 0, int maxWidth = 0, int maxHeight = 0, bool watermark = false)
 {
     return(ConfigurationManager.AppSettings("SiteUrl") + VirtualPathSlug(fileinfo, width, height, size, maxWidth, maxHeight, watermark));
 }
 public static string AbsoluteShareUrlSlug(this FileInfo fileinfo)
 {
     return(AbsoluteUrlSlug(fileinfo, 1200, 630, 0, 0, 0, bool.Parse(ConfigurationManager.AppSettings("ImageWatermarkShareEnabled"))));
 }
 public static string GetWwwFolderPhysicalPathById(string folderId)
 {
     return(Server.MapWwwPath(ConfigurationManager.AppSettings("Folders:" + folderId)));
 }
예제 #9
0
 public string GetValue(string key)
 {
     return(ConfigurationManager.AppSettings(key));
 }