AppLinkTagHelper Class
Definition
- Namespace
- Cuemon.AspNetCore.Razor.TagHelpers
- Assemblies
- 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)
{
Href = "css/site.css"
};
var stylesheetHref = $"{tagHelper.Options.GetFormattedBaseUrl()}{tagHelper.Href}?v={version.Version}";
Console.WriteLine(stylesheetHref);
}
}
Constructors
| Name | Description |
|---|---|
| AppLinkTagHelper(IOptions<AppTagHelperOptions>, ICacheBusting) | Initializes a new instance of the AppLinkTagHelper class. |
See Also
LinkTagHelper<TOptions>