private void AttachDynamicScripts(HttpContextBase httpContext) { var paths = DynamicScriptExtensions.GetRegisteredPaths(httpContext).ToArray(); if (paths.Any()) { const string headerName = "X-Scripts"; var bundle = DynamicBundleCreator.GerOrCreateScriptBundleFor(paths); string urls = Scripts.RenderFormat("{0}", bundle.Path) .ToHtmlString() .Trim() .Replace(Environment.NewLine, ","); httpContext.Response.Headers.Add(headerName, urls); } }
public static IHtmlString RenderDynamicScripts(this HtmlHelper helper) { if (helper == null) { throw new ArgumentNullException(nameof(helper)); } var registeredPaths = GetRegisteredPaths(helper.ViewContext.HttpContext); if (!registeredPaths.Any()) { return(MvcHtmlString.Empty); } var bundle = DynamicBundleCreator.GerOrCreateScriptBundleFor(registeredPaths); return(Scripts.Render(bundle.Path)); }