Class AppLinkTagHelper
- Namespace
- Cuemon.AspNetCore.Razor.TagHelpers
- Assembly
- Cuemon.AspNetCore.Razor.TagHelpers.dll
Provides an implementation targeting <link> elements that supports ICacheBusting versioning of a static resource placed on a location outside (but tied to) your application. This class cannot be inherited.
[HtmlTargetElement("app-link")]
public sealed class AppLinkTagHelper : LinkTagHelper<AppTagHelperOptions>, ITagHelper, ITagHelperComponent, IConfigurable<AppTagHelperOptions>
- Inheritance
-
AppLinkTagHelper
- Implements
- Inherited Members
Examples
The following example demonstrates how to create with application-scoped options.
using System;
using Cuemon.AspNetCore.Configuration;
using Cuemon.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.Options;
namespace MyApp.Examples;
public static class AppLinkTagHelperExample
{
private sealed class StylesheetVersion : ICacheBusting
{
public string Version => "1.0.0";
}
public static void Demonstrate()
{
var options = new AppTagHelperOptions
{
Scheme = ProtocolUriScheme.Relative,
BaseUrl = "static.cuemon.net"
};
var version = new StylesheetVersion();
var tagHelper = new AppLinkTagHelper(Options.Create(options), version);
var stylesheetHref = $"{options.GetFormattedBaseUrl()}css/site.css?v={version.Version}";
Console.WriteLine(stylesheetHref);
Console.WriteLine(tagHelper.GetType().Name);
}
}
Constructors
AppLinkTagHelper(IOptions<AppTagHelperOptions>, ICacheBusting)
Initializes a new instance of the AppLinkTagHelper class.
public AppLinkTagHelper(IOptions<AppTagHelperOptions> setup, ICacheBusting cacheBusting = null)
Parameters
setupIOptions<AppTagHelperOptions>The AppTagHelperOptions which need to be configured.
cacheBustingICacheBustingAn optional object implementing the ICacheBusting interface.
See Also
LinkTagHelper<TOptions>