ScriptTagHelper Class

Definition

ITagHelper implementation targeting <script> elements that supports fallback src paths.

public ref class ScriptTagHelper : Microsoft::AspNetCore::Mvc::Razor::TagHelpers::UrlResolutionTagHelper
[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElement("script", Attributes="asp-src-include")]
[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElement("script", Attributes="asp-src-exclude")]
[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElement("script", Attributes="asp-fallback-src")]
[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElement("script", Attributes="asp-fallback-src-include")]
[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElement("script", Attributes="asp-fallback-src-exclude")]
[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElement("script", Attributes="asp-fallback-test")]
[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElement("script", Attributes="asp-append-version")]
public class ScriptTagHelper : Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper
type ScriptTagHelper = class
    inherit UrlResolutionTagHelper
Public Class ScriptTagHelper
Inherits UrlResolutionTagHelper
Inheritance
Attributes

Remarks

The tag helper won't process for cases with just the 'src' attribute.

Constructors

ScriptTagHelper(IHostingEnvironment, IMemoryCache, HtmlEncoder, JavaScriptEncoder, IUrlHelperFactory)

Creates a new ScriptTagHelper.

ScriptTagHelper(IHostingEnvironment, TagHelperMemoryCacheProvider, IFileVersionProvider, HtmlEncoder, JavaScriptEncoder, IUrlHelperFactory)

Creates a new ScriptTagHelper.

ScriptTagHelper(IWebHostEnvironment, TagHelperMemoryCacheProvider, IFileVersionProvider, HtmlEncoder, JavaScriptEncoder, IUrlHelperFactory)

Creates a new ScriptTagHelper.

Properties

AppendVersion

Value indicating if file version should be appended to src urls.

Cache

Gets the IMemoryCache used to store globbed urls.

FallbackSrc

The URL of a Script tag to fallback to in the case the primary one fails.

FallbackSrcExclude

A comma separated list of globbed file patterns of JavaScript scripts to exclude from the fallback list, in the case the primary one fails. The glob patterns are assessed relative to the application's 'webroot' setting. Must be used in conjunction with FallbackSrcInclude.

FallbackSrcInclude

A comma separated list of globbed file patterns of JavaScript scripts to fallback to in the case the primary one fails. The glob patterns are assessed relative to the application's 'webroot' setting.

FallbackTestExpression

The script method defined in the primary script to use for the fallback test.

GlobbingUrlBuilder

Gets the GlobbingUrlBuilder used to populate included and excluded urls.

HostingEnvironment

Gets the IWebHostEnvironment for the application.

HtmlEncoder (Inherited from UrlResolutionTagHelper)
JavaScriptEncoder

Gets the JavaScriptEncoder used to encode fallback information.

Order
Src

Address of the external script to use.

SrcExclude

A comma separated list of globbed file patterns of JavaScript scripts to exclude from loading. The glob patterns are assessed relative to the application's 'webroot' setting. Must be used in conjunction with SrcInclude.

SrcInclude

A comma separated list of globbed file patterns of JavaScript scripts to load. The glob patterns are assessed relative to the application's 'webroot' setting.

SuppressFallbackIntegrity

Boolean value that determines if an integrity hash will be compared with FallbackSrc value.

UrlHelperFactory (Inherited from UrlResolutionTagHelper)
ViewContext (Inherited from UrlResolutionTagHelper)

Methods

Init(TagHelperContext)

Initializes the ITagHelper with the given context. Additions to Items should be done within this method to ensure they're added prior to executing the children.

(Inherited from TagHelper)
Process(TagHelperContext, TagHelperOutput)
ProcessAsync(TagHelperContext, TagHelperOutput)

Asynchronously executes the TagHelper with the given context and output.

(Inherited from TagHelper)
ProcessUrlAttribute(String, TagHelperOutput)

Resolves and updates URL values starting with '~/' (relative to the application's 'webroot' setting) for output's Attributes whose Name is attributeName.

(Inherited from UrlResolutionTagHelper)
TryResolveUrl(String, IHtmlContent)

Tries to resolve the given url value relative to the application's 'webroot' setting.

(Inherited from UrlResolutionTagHelper)
TryResolveUrl(String, String)

Tries to resolve the given url value relative to the application's 'webroot' setting.

(Inherited from UrlResolutionTagHelper)

Applies to