WebResourceAttribute.PerformSubstitution Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets a Boolean value that determines whether, during processing of the embedded resource referenced by the WebResourceAttribute class, other Web resource URLs are parsed and replaced with the full path to the resource.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

Public Property PerformSubstitution As Boolean

Property Value

Type: System.Boolean

true if embedded resources are resolved during processing of the resource; otherwise, false. The default is false.

When a resource is streamed from the assembly to the response, references to other Web resources in the embedded resources can be resolved at this time, if the PerformSubstitution property is set to true.

The following code example demonstrates how to query the value of the PerformSubstitution property. In this example, the WebResourceAttribute attribute of the HTML file Help.htm is defined with the PerformSubstitution property set to true.

This code example is part of a larger example provided for the WebResourceAttribute class.

<%@ Page Language="VB" %>
<%@ Register TagPrefix="AspNetSamples" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB.Controls" %>
<%@ Import Namespace="System.Reflection" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    ' Get the assembly metatdata.
    Dim clsType As Type = GetType(MyCustomControl)
    Dim a As Assembly = clsType.Assembly

    For Each attr As Attribute In Attribute.GetCustomAttributes(a)
      'Check for WebResource attributes.
      If attr.GetType() Is GetType(WebResourceAttribute) Then
        Dim wra As WebResourceAttribute = CType(attr, WebResourceAttribute)
        Response.Write("Resource in the assembly: " & wra.WebResource.ToString() & _
        " with ContentType = " & wra.ContentType.ToString() & _
        " and PerformsSubstitution = " & wra.PerformSubstitution.ToString() & "</br>")
      End If
    Next attr

  End Sub


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>WebResourceAttribute Example</title>
    <form id="form1" runat="server">
      <AspNetSamples:MyCustomControl id="MyCustomControl1" runat="server">

An example of an HTML Web resource that could be used in this example is shown next. Note that the WebResource syntax is used when you set the PerformSubstitution property to true for the resource.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >


<title>Included Help Page</title>




<img alt="help image" src=<% = WebResource("image1.jpg") %> />

Included help file.




.NET Framework
Available since 2.0
Return to top