public static string RouteResource(this UrlHelper helper, string assembly, string name) { var route = helper.RouteCollection["ResourceManager"]; var baselocation = new VirtualPathLocation("~/"); var location = ResourceLocations.GetLocation(baselocation, assembly, name); var config = ResourceConfigurationManager.GetConfiguration(); var resource = config.GetResource(location); if (route == null) return ResourceURLProvider.GetURLProvider().GetURLFactory(HttpContext.Current).GetURL(resource); return RoutingResourceURLFactory.GetURL(route, helper.RequestContext, resource); }
public void ProcessRequest(HttpContext context) { HttpRequest request = context.Request; HttpResponse response = context.Response; string q = request.QueryString[null]; string[] ps = q == null ? new string[0] : q.Split('-'); string version = ps.Length > 0 ? ps[0] : null; /*string c = context.Request.QueryString["c"]; if (c != null) Thread.CurrentThread.CurrentCulture = new CultureInfo(int.Parse(c, NumberStyles.AllowHexSpecifier)); string cu = context.Request.QueryString["cu"]; if (cu != null) Thread.CurrentThread.CurrentUICulture = new CultureInfo(int.Parse(cu, NumberStyles.AllowHexSpecifier));*/ string path = request.AppRelativeCurrentExecutionFilePath; path = path.Substring(2, path.Length - 10); // Trim off .res.axd string assembly = null; if (path.StartsWith(_assemblyPath, StringComparison.InvariantCultureIgnoreCase)) { int i = path.IndexOf('/', 11); if (i > 0) { assembly = path.Substring(11, i - 11); path = path.Substring(i + 1); } } IResourceLocation location; if (assembly != null) location = ResourceLocations.GetAssemblyLocation(Assembly.Load(assembly), path); else location = new VirtualPathLocation("~/", path); IResourceConfiguration config = ResourceConfigurationManager.GetConfiguration(); IResourceURLFactory urlFactory = ResourceURLProvider.GetURLProvider().GetURLFactory(context); IResource res = config.GetResource(location); if (ps.Length > 1 && ps[1] != "") System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(int.Parse(ps[1], NumberStyles.AllowHexSpecifier)); if (ps.Length > 2 && ps[2] != "") System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(int.Parse(ps[2], NumberStyles.AllowHexSpecifier)); string v = ToHex(res.Version); if (v != version) { response.RedirectLocation = String.Format("{0}?{1}{2}{3}", request.Path, v, ps.Length > 1 ? "-" + ps[1] : null, ps.Length > 2 ? "-" + ps[2] : null); response.StatusCode = 301; return; } ProcessRequest(request, response, urlFactory, res, version); }
private static IEnumerable<IResourceLocation> GetLocations(HtmlHelper helper, string assemblyName, string resourceName) { var baselocation = new VirtualPathLocation("~/"); return ResourceLocations.GetLocations(baselocation, assemblyName, resourceName); }