/// <summary> /// 处理资源的请求 /// </summary> /// <param name="context">Http请求上下文</param> public void ProcessRequest(HttpContext context) { string type = String.Empty, typeValue = String.Empty; if (!String.IsNullOrEmpty(typeValue = context.Request["icon"])) { type = "icon"; } //else if (!String.IsNullOrEmpty(typeValue = context.Request["js"])) //{ // type = "js"; //} //else if (!String.IsNullOrEmpty(typeValue = context.Request["lang"])) //{ // type = "lang"; //} //else if (!String.IsNullOrEmpty(typeValue = context.Request["theme"])) //{ // type = "theme"; //} //else if (!String.IsNullOrEmpty(typeValue = context.Request["css"])) //{ // type = "css"; //} //else if (!String.IsNullOrEmpty(typeValue = context.Request["image"])) //{ // type = "image"; //} //string resName = "ExtAspNet."; switch (type) { case "icon": if (!typeValue.EndsWith(".png") && !typeValue.EndsWith(".gif")) { typeValue = IconHelper.GetName((Icon)Enum.Parse(typeof(Icon), typeValue)); } //resName += "res.icon." + typeValue; string serverPath = String.Format("{0}/{1}", GlobalConfig.GetIconBasePath(), typeValue); context.Response.WriteFile(context.Server.MapPath(serverPath)); context.Response.ContentType = "image/" + GetImageFormat(typeValue); break; } // 缓存一年,只能通过改变 URL 来强制更新缓存 context.Response.Cache.SetExpires(DateTime.Now.AddYears(1)); context.Response.Cache.SetCacheability(HttpCacheability.Public); }
/// <summary> /// 获得图标的服务器地址 /// </summary> /// <param name="icon">图标</param> /// <returns>图标的服务器地址</returns> public static string GetIconUrl(Icon icon) { //return ResourceHelper.GetWebResourceUrl(String.Format("ExtAspNet.res.icon.{0}", IconHelper.GetName(icon))); if (icon == Icon.None) { return(String.Empty); } else { return(String.Format("{0}/{1}", GlobalConfig.GetIconBasePath(), IconHelper.GetName(icon))); } }