/// <summary> /// Synchronously executes the TagHelper /// </summary> public override void Process(TagHelperContext context, TagHelperOutput output) { if (string.IsNullOrEmpty(output.TagName)) { return; } string src = LinkTagHelper.GetValue("src", output); if (string.IsNullOrEmpty(src)) { return; } if (Pipeline.TryGetAssetFromRoute(src, out IAsset asset) && !output.Attributes.ContainsName("inline")) { Options.EnsureDefaults(HostingEnvironment); if (Options.EnableTagHelperBundling == true) { src = GenerateHash(asset); } else { WriteIndividualTags(output, asset); } } output.Attributes.SetAttribute("src", src); }
/// <summary> /// Synchronously executes the TagHelper /// </summary> public override void Process(TagHelperContext context, TagHelperOutput output) { if (string.IsNullOrEmpty(output.TagName)) { return; } string src = LinkTagHelper.GetValue("src", output); if (string.IsNullOrEmpty(src)) { return; } if (CurrentViewContext.HttpContext.Request.PathBase.HasValue) { src = src.TrimStart(CurrentViewContext.HttpContext.Request.PathBase.Value.ToCharArray()); } if (Pipeline.TryGetAssetFromRoute(src, out IAsset asset) && !output.Attributes.ContainsName("inline")) { if (Options.EnableTagHelperBundling == true) { if (CurrentViewContext.HttpContext.Request.PathBase.HasValue) { src = CurrentViewContext.HttpContext.Request.PathBase.Value + GenerateHash(asset); } else { src = GenerateHash(asset); } output.Attributes.SetAttribute("src", src); } else { WriteIndividualTags(output, asset); } } }
/// <summary> /// Synchronously executes the TagHelper /// </summary> public override void Process(TagHelperContext context, TagHelperOutput output) { if (string.IsNullOrEmpty(output.TagName)) { return; } string src = LinkTagHelper.GetValue("src", output); if (string.IsNullOrEmpty(src)) { return; } string pathBase = null; if (CurrentViewContext.HttpContext.Request.PathBase.HasValue) { pathBase = CurrentViewContext.HttpContext.Request.PathBase.Value; } if (pathBase != null && src.StartsWith(pathBase)) { src = src.Substring(pathBase.Length); } if (Pipeline.TryGetAssetFromRoute(src, out IAsset asset) && !output.Attributes.ContainsName("inline")) { if (Options.EnableTagHelperBundling == true) { src = $"{pathBase}{GenerateHash(asset)}"; output.Attributes.SetAttribute("src", src); } else { WriteIndividualTags(output, asset); } } }