InlineTagHelper Class
Base class for TagHelpers that inline external files into HTML elements with caching support.
public abstract class InlineTagHelper : TagHelperRemarks
This abstract class provides functionality to read files from the web root, cache their contents, and automatically invalidate the cache when files change. It supports reading files as both text and Base64-encoded strings.
- Inheritance
TagHelperInlineTagHelper
Constructors
| Name | Description |
|---|---|
| InlineTagHelper(IWebHostEnvironment, IMemoryCache, ILogger) | Initializes a new instance of the InlineTagHelper class. |
InlineTagHelper(IWebHostEnvironment, IMemoryCache, ILogger)
InlineTagHelper.csInitializes a new instance of the InlineTagHelper class.
protected InlineTagHelper(IWebHostEnvironment webHostEnvironment, IMemoryCache cache, ILogger logger)Parameters
webHostEnvironmentIWebHostEnvironment- The web host environment for accessing web root files.
cacheIMemoryCache- The memory cache for storing file contents.
loggerILogger- The logger used to report missing files.
Methods
| Name | Description |
|---|---|
| GetFileContentAsync(string?) | Gets the file content as a string with caching support. |
| GetFileContentBase64Async(string?) | Gets the file content as a Base64-encoded string with caching support. |
GetFileContentAsync(string?)
InlineTagHelper.csGets the file content as a string with caching support.
Parameters
pathstring?- The relative path to the file in the web root.
Returns
Task<string?> The file content as a string, or null if the path is null or the file doesn't exist.
GetFileContentBase64Async(string?)
InlineTagHelper.csGets the file content as a Base64-encoded string with caching support.
Parameters
pathstring?- The relative path to the file in the web root.
Returns
Task<string?> The file content as a Base64 string, or null if the path is null or the file doesn't exist.