Open dandros opened 6 years ago
same with miniblog https://github.com/madskristensen/Miniblog.Core/issues/40
I'm running a test app on a sub domain, if the app has been idling and restarts I get 500s for my bundles (I have to refresh the page) guessing a similar issue?
I fixed this temporally by adding a customer tag helper that extends the link tag helper. It adds a new attribute on the tag called "RenderRelative". If that attribute is true, it drops the leading '/' to fix for IIS sub apps. It would be nice if a more long term fix were included in the nuget project itself.
public class RelativeRouteLinkTagHelper : LinkTagHelper
{
public RelativeRouteLinkTagHelper(IWebHostEnvironment env, IMemoryCache cache, IAssetPipeline pipeline, IOptionsMonitor<WebOptimizerOptions> options) : base(env, cache, pipeline, options)
{
}
public override void Process(TagHelperContext context, TagHelperOutput output)
{
base.Process(context, output);
output.Attributes.TryGetAttribute("RenderRelative", out var renderRelative);
var isTrue = "true".Equals(renderRelative?.Value?.ToString(), StringComparison.CurrentCultureIgnoreCase);
if (!isTrue) return;
output.Attributes.TryGetAttribute("href", out var hrefAtr);
var href = hrefAtr?.Value as string;
if(!string.IsNullOrEmpty(href))
output.Attributes.SetAttribute("href", href.TrimStart('/'));
}
}
In layout I put ~ to resolve app root.
It generates script tag without cache busting param.