상속: System.Web.HttpTaskAsyncHandler, IRouteHandler
예제 #1
0
        public static void Register(
            RouteCollection routes,
            TimeSpan?maxAge = null,
            string version  = null)
        {
            CachedRoute sc = new CachedRoute();

            sc.MaxAge = maxAge == null?TimeSpan.FromDays(30) : maxAge.Value;

            if (string.IsNullOrWhiteSpace(version))
            {
                version = System.Web.Configuration.WebConfigurationManager.AppSettings["Static-Content-Version"];
                if (string.IsNullOrWhiteSpace(version))
                {
                    version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                }
            }

            Version = version;

            var route = new Route("cached/{version}/{*name}", sc);

            route.Defaults            = new RouteValueDictionary();
            route.Defaults["version"] = "1";
            routes.Add(route);
        }
예제 #2
0
            public string ToAbsolute(string url)
            {
                if (string.IsNullOrWhiteSpace(url))
                {
                    return(RootUri.PathAndQuery);
                }

                if (
                    url.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
                    url.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
                {
                    return(url);
                }

                if (url.StartsWith("/"))
                {
                    return(url);
                }

                Uri n = new Uri(RootUri, url);

                return(CachedRoute.CachedUrl(n.PathAndQuery).ToString());
            }
예제 #3
0
        public static void Register(
            RouteCollection routes,
            TimeSpan? maxAge = null,
            string version = null)
        {
            CachedRoute sc = new CachedRoute();
            sc.MaxAge = maxAge == null ? TimeSpan.FromDays(30) : maxAge.Value;

            if (string.IsNullOrWhiteSpace(version))
            {
                version = System.Web.Configuration.WebConfigurationManager.AppSettings["Static-Content-Version"];
                if (string.IsNullOrWhiteSpace(version))
                {
                    version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                }
            }

            Version = version;

            var route = new Route("cached/{version}/{*name}", sc);
            route.Defaults = new RouteValueDictionary();
            route.Defaults["version"] = "1";
            routes.Add(route);
        }