Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
1583 lines (1362 sloc) 116 KB
<Type Name="HttpServerUtility" FullName="System.Web.HttpServerUtility">
<TypeSignature Language="C#" Value="public sealed class HttpServerUtility" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit HttpServerUtility extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Web.HttpServerUtility" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class HttpServerUtility" />
<TypeSignature Language="C++ CLI" Value="public ref class HttpServerUtility sealed" />
<TypeSignature Language="F#" Value="type HttpServerUtility = class" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Provides helper methods for processing Web requests.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The methods and properties of the <xref:System.Web.HttpServerUtility> class are exposed through the intrinsic <xref:System.Web.HttpContext.Server%2A> object provided by ASP.NET.
## Examples
A Visual Studio Web site project with source code is available to accompany this topic: [Download](https://go.microsoft.com/fwlink/?LinkId=192870).
The following example demonstrates how to use the <xref:System.Web.HttpServerUtility.HtmlEncode%2A> method and the <xref:System.Web.HttpServerUtility.UrlEncode%2A> method of the <xref:System.Web.HttpServerUtility> class. The <xref:System.Web.HttpServerUtility.HtmlEncode%2A> method helps ensure that any user-supplied string input will be rendered as static text in browsers instead of executable script or HTML elements. The <xref:System.Web.HttpServerUtility.UrlEncode%2A> method encodes URLs so that they are correctly transmitted in the HTTP stream.
[!code-aspx-csharp[System.Web.HttpServerUtility1#1](~/samples/snippets/csharp/VS_Snippets_WebNet/System.Web.HttpServerUtility1/cs/HttpServerUtilityCS.aspx#1)]
[!code-aspx-vb[System.Web.HttpServerUtility1#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.Web.HttpServerUtility1/vb/HttpServerUtilityVB.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.HttpContext" />
</Docs>
<Members>
<Member MemberName="ClearError">
<MemberSignature Language="C#" Value="public void ClearError ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void ClearError() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.ClearError" />
<MemberSignature Language="VB.NET" Value="Public Sub ClearError ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void ClearError();" />
<MemberSignature Language="F#" Value="member this.ClearError : unit -&gt; unit" Usage="httpServerUtility.ClearError " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Clears the previous exception.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example clears the last exception that was thrown.
[!code-csharp[Classic HttpServerUtility.ClearError Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.ClearError Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.ClearError Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.ClearError Example/VB/source.vb#1)]
]]></format>
</remarks>
<altmember cref="M:System.Web.HttpServerUtility.GetLastError" />
</Docs>
</Member>
<MemberGroup MemberName="CreateObject">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Creates a server instance of a COM object.</summary>
</Docs>
</MemberGroup>
<Member MemberName="CreateObject">
<MemberSignature Language="C#" Value="public object CreateObject (string progID);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance object CreateObject(string progID) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.CreateObject(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function CreateObject (progID As String) As Object" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Object ^ CreateObject(System::String ^ progID);" />
<MemberSignature Language="F#" Value="member this.CreateObject : string -&gt; obj" Usage="httpServerUtility.CreateObject progID" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="progID" Type="System.String" />
</Parameters>
<Docs>
<param name="progID">The class or type of object to create an instance of.</param>
<summary>Creates a server instance of a COM object identified by the object's programmatic identifier (ProgID).</summary>
<returns>The new object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example creates an object by using the object's ProgID.
[!code-csharp[Classic HttpServerUtility.CreateObject Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.CreateObject Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.CreateObject Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.CreateObject Example/VB/source.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.Web.HttpException">An instance of the object could not be created.</exception>
<altmember cref="M:System.Web.HttpServerUtility.CreateObjectFromClsid(System.String)" />
</Docs>
</Member>
<Member MemberName="CreateObject">
<MemberSignature Language="C#" Value="public object CreateObject (Type type);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance object CreateObject(class System.Type type) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.CreateObject(System.Type)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Object ^ CreateObject(Type ^ type);" />
<MemberSignature Language="F#" Value="member this.CreateObject : Type -&gt; obj" Usage="httpServerUtility.CreateObject type" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="type" Type="System.Type" />
</Parameters>
<Docs>
<param name="type">A <see cref="T:System.Type" /> representing the object to create.</param>
<summary>Creates a server instance of a COM object identified by the object's type.</summary>
<returns>The new object.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="CreateObjectFromClsid">
<MemberSignature Language="C#" Value="public object CreateObjectFromClsid (string clsid);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance object CreateObjectFromClsid(string clsid) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.CreateObjectFromClsid(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function CreateObjectFromClsid (clsid As String) As Object" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Object ^ CreateObjectFromClsid(System::String ^ clsid);" />
<MemberSignature Language="F#" Value="member this.CreateObjectFromClsid : string -&gt; obj" Usage="httpServerUtility.CreateObjectFromClsid clsid" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="clsid" Type="System.String" />
</Parameters>
<Docs>
<param name="clsid">The class identifier of the object to create an instance of.</param>
<summary>Creates a server instance of a COM object identified by the object's class identifier (CLSID).</summary>
<returns>The new object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example demonstrates how to use the <xref:System.Web.HttpServerUtility.CreateObjectFromClsid%2A> method to create a server instance of a COM object.
[!code-csharp[Classic HttpServerUtility.CreateObjectFromClsid Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.CreateObjectFromClsid Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.CreateObjectFromClsid Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.CreateObjectFromClsid Example/VB/source.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.Web.HttpException">An instance of the object could not be created.</exception>
<altmember cref="M:System.Web.HttpServerUtility.CreateObject(System.String)" />
</Docs>
</Member>
<MemberGroup MemberName="Execute">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Executes the handler for a specified resource in the context of the current request and returns execution to the page that invoked it.</summary>
</Docs>
</MemberGroup>
<Member MemberName="Execute">
<MemberSignature Language="C#" Value="public void Execute (string path);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Execute(string path) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.Execute(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub Execute (path As String)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void Execute(System::String ^ path);" />
<MemberSignature Language="F#" Value="member this.Execute : string -&gt; unit" Usage="httpServerUtility.Execute path" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<param name="path">The URL path to execute.</param>
<summary>Executes the handler for the specified virtual path in the context of the current request.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.HttpServerUtility.Execute%2A> method continues execution of the original page after execution of the new page is completed. The <xref:System.Web.HttpServerUtility.Transfer%2A> method unconditionally transfers execution to another handler.
ASP.NET does not verify that the current user is authorized to view the resource delivered by the <xref:System.Web.HttpServerUtility.Execute%2A> method. Although the ASP.NET authorization and authentication logic runs before the original resource handler is called, ASP.NET directly calls the handler indicated by the <xref:System.Web.HttpServerUtility.Execute%2A> method and does not rerun authentication and authorization logic for the new resource. If your application's security policy requires clients to have appropriate authorization to access the resource, the application should force reauthorization or provide a custom access-control mechanism.
You can force reauthorization by using the <xref:System.Web.HttpResponse.Redirect%2A> method instead of the <xref:System.Web.HttpServerUtility.Execute%2A> method. <xref:System.Web.HttpResponse.Redirect%2A> performs a client-side redirect in which the browser requests the new resource. Because this redirect is a new request entering the system, it is subjected to all the authentication and authorization logic of both Internet Information Services (IIS) and ASP.NET security policy.
You can verify that the user has permission to view the resource by incorporating a custom authorization method that uses the <xref:System.Security.Principal.WindowsPrincipal.IsInRole%2A> method before the application calls the <xref:System.Web.HttpServerUtility.Execute%2A> method.
## Examples
The following example displays the .aspx page "Updateinfo.aspx" in the current directory. Program execution returns to the starting page after the Updateinfo.aspx page is displayed.
[!code-csharp[Classic HttpServerUtility.Execute Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.Execute Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.Execute Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.Execute Example/VB/source.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.Web.HttpException">The current <see cref="T:System.Web.HttpContext" /> is <see langword="null" />.
-or-
An error occurred while executing the handler specified by <paramref name="path" />.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="path" /> is <see langword="null" />.
-or-
<paramref name="path" /> is not a virtual path.</exception>
</Docs>
</Member>
<Member MemberName="Execute">
<MemberSignature Language="C#" Value="public void Execute (string path, bool preserveForm);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Execute(string path, bool preserveForm) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.Execute(System.String,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub Execute (path As String, preserveForm As Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void Execute(System::String ^ path, bool preserveForm);" />
<MemberSignature Language="F#" Value="member this.Execute : string * bool -&gt; unit" Usage="httpServerUtility.Execute (path, preserveForm)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="preserveForm" Type="System.Boolean" Index="1" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
</Parameters>
<Docs>
<param name="path">The URL path to execute.</param>
<param name="preserveForm">
<see langword="true" /> to preserve the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections; <see langword="false" /> to clear the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections.</param>
<summary>Executes the handler for the specified virtual path in the context of the current request and specifies whether to clear the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to execute the .aspx page `Updateinfo.aspx` in the current request and preserve the <xref:System.Web.HttpRequest.QueryString%2A> and <xref:System.Web.HttpRequest.Form%2A> collections. Program execution returns to the starting page after `Updateinfo.aspx` is displayed.
[!code-csharp[HttpServerUtility.Execute#1](~/samples/snippets/csharp/VS_Snippets_WebNet/HttpServerUtility.Execute/CS/httpserverutility.execute_cs.aspx#1)]
[!code-vb[HttpServerUtility.Execute#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/HttpServerUtility.Execute/VB/httpserverutility.execute_vb.aspx#1)]
]]></format>
</remarks>
<exception cref="T:System.Web.HttpException">The current <see cref="T:System.Web.HttpContext" /> is <see langword="null" />.
-or-
An error occurred while executing the handler specified by <paramref name="path" />.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="path" /> is <see langword="null" />.
-or-
<paramref name="path" /> is not a virtual path.</exception>
<altmember cref="Overload:System.Web.HttpServerUtility.Transfer" />
</Docs>
</Member>
<Member MemberName="Execute">
<MemberSignature Language="C#" Value="public void Execute (string path, System.IO.TextWriter writer);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Execute(string path, class System.IO.TextWriter writer) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.Execute(System.String,System.IO.TextWriter)" />
<MemberSignature Language="VB.NET" Value="Public Sub Execute (path As String, writer As TextWriter)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void Execute(System::String ^ path, System::IO::TextWriter ^ writer);" />
<MemberSignature Language="F#" Value="member this.Execute : string * System.IO.TextWriter -&gt; unit" Usage="httpServerUtility.Execute (path, writer)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
<Parameter Name="writer" Type="System.IO.TextWriter" />
</Parameters>
<Docs>
<param name="path">The URL path to execute.</param>
<param name="writer">The <see cref="T:System.IO.TextWriter" /> to capture the output.</param>
<summary>Executes the handler for the specified virtual path in the context of the current request. A <see cref="T:System.IO.TextWriter" /> captures output from the executed handler.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.HttpServerUtility.Execute%2A> method continues execution of the original request after execution of the virtual path specified is completed. The <xref:System.Web.HttpServerUtility.Transfer%2A> method unconditionally transfers execution to another handler.
ASP.NET does not verify that the current user is authorized to view the resource delivered by the <xref:System.Web.HttpServerUtility.Execute%2A> method. Although the ASP.NET authorization and authentication logic runs before the original resource handler is called, ASP.NET directly calls the handler indicated by the <xref:System.Web.HttpServerUtility.Execute%2A> method and does not rerun authentication and authorization logic for the new resource. If your application's security policy requires clients to have appropriate authorization to access the resource, the application should force reauthorization or provide a custom access-control mechanism.
You can force reauthorization by using the <xref:System.Web.HttpResponse.Redirect%2A> method instead of the <xref:System.Web.HttpServerUtility.Execute%2A> method. <xref:System.Web.HttpResponse.Redirect%2A> performs a client-side redirect in which the browser requests the new resource. Because this redirect is a new request entering the system, it is subjected to all the authentication and authorization logic of both Internet Information Services (IIS) and ASP.NET security policy.
You can verify that the user has permission to view the resource by incorporating a custom authorization method that uses the <xref:System.Security.Principal.WindowsPrincipal.IsInRole%2A> method before the application calls the <xref:System.Web.HttpServerUtility.Execute%2A> method.
## Examples
The following example executes the `Login.aspx` page on the server in the current directory and receives the output from the page through the <xref:System.IO.StringWriter> object `writer`. It writes the HTML stream received from `writer` to the HTTP output stream.
[!code-csharp[Classic HttpServerUtility.Execute1 Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.Execute1 Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.Execute1 Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.Execute1 Example/VB/source.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.Web.HttpException">The current <see cref="T:System.Web.HttpContext" /> is <see langword="null" />.
-or-
An error occurred while executing the handler specified by <paramref name="path" />.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="path" /> is <see langword="null" />.
-or-
<paramref name="path" /> is not a virtual path.</exception>
<altmember cref="Overload:System.Web.HttpServerUtility.Transfer" />
</Docs>
</Member>
<Member MemberName="Execute">
<MemberSignature Language="C#" Value="public void Execute (string path, System.IO.TextWriter writer, bool preserveForm);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Execute(string path, class System.IO.TextWriter writer, bool preserveForm) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.Execute(System.String,System.IO.TextWriter,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub Execute (path As String, writer As TextWriter, preserveForm As Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void Execute(System::String ^ path, System::IO::TextWriter ^ writer, bool preserveForm);" />
<MemberSignature Language="F#" Value="member this.Execute : string * System.IO.TextWriter * bool -&gt; unit" Usage="httpServerUtility.Execute (path, writer, preserveForm)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="writer" Type="System.IO.TextWriter" Index="1" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="preserveForm" Type="System.Boolean" Index="2" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
</Parameters>
<Docs>
<param name="path">The URL path to execute.</param>
<param name="writer">The <see cref="T:System.IO.TextWriter" /> to capture the output.</param>
<param name="preserveForm">
<see langword="true" /> to preserve the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections; <see langword="false" /> to clear the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections.</param>
<summary>Executes the handler for the specified virtual path in the context of the current request. A <see cref="T:System.IO.TextWriter" /> captures output from the page and a Boolean parameter specifies whether to clear the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.HttpServerUtility.Execute%2A> method continues execution of the original request after execution of the specified virtual path is completed. The <xref:System.Web.HttpServerUtility.Transfer%2A> method unconditionally transfers execution to another handler.
ASP.NET does not verify that the current user is authorized to view the resource delivered by the <xref:System.Web.HttpServerUtility.Execute%2A> method. Although the ASP.NET authorization and authentication logic runs before the original resource handler is called, ASP.NET directly calls the handler indicated by the <xref:System.Web.HttpServerUtility.Execute%2A> method and does not rerun authentication and authorization logic for the new resource. If your application's security policy requires clients to have appropriate authorization to access the resource, the application should force reauthorization or provide a custom access-control mechanism.
You can force reauthorization by using the <xref:System.Web.HttpResponse.Redirect%2A> method instead of the <xref:System.Web.HttpServerUtility.Execute%2A> method. <xref:System.Web.HttpResponse.Redirect%2A> performs a client-side redirect in which the browser requests the new resource. Because this redirect is a new request entering the system, it is subjected to all the authentication and authorization logic of both Internet Information Services (IIS) and ASP.NET security policy.
You can verify that the user has permission to view the resource by incorporating a custom authorization method that uses the <xref:System.Security.Principal.WindowsPrincipal.IsInRole%2A> method before the application calls the <xref:System.Web.HttpServerUtility.Execute%2A> method.
## Examples
The following example executes the `Login.aspx` page on the server in the current directory and receives the output from the page through the <xref:System.IO.StringWriter> object `writer`. It writes the HTML stream received from `writer` to the HTTP output stream. The contents of the <xref:System.Web.HttpRequest.Form%2A> and <xref:System.Web.HttpRequest.QueryString%2A> collections are preserved.
[!code-csharp[HttpServerUtility.Execute02#1](~/samples/snippets/csharp/VS_Snippets_WebNet/HttpServerUtility.Execute02/CS/httpserverutility.execute02_cs.aspx#1)]
[!code-vb[HttpServerUtility.Execute02#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/HttpServerUtility.Execute02/VB/httpserverutility.execute02_vb.aspx#1)]
]]></format>
</remarks>
<exception cref="T:System.Web.HttpException">The current <see cref="T:System.Web.HttpContext" /> is a null reference (<see langword="Nothing" /> in Visual Basic).
-or-
<paramref name="path" /> ends with a period (.).
-or-
An error occurred while executing the handler specified by <paramref name="path" />.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="path" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="path" /> is not a virtual path.</exception>
<altmember cref="Overload:System.Web.HttpServerUtility.Transfer" />
</Docs>
</Member>
<Member MemberName="Execute">
<MemberSignature Language="C#" Value="public void Execute (System.Web.IHttpHandler handler, System.IO.TextWriter writer, bool preserveForm);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Execute(class System.Web.IHttpHandler handler, class System.IO.TextWriter writer, bool preserveForm) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.Execute(System.Web.IHttpHandler,System.IO.TextWriter,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub Execute (handler As IHttpHandler, writer As TextWriter, preserveForm As Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void Execute(System::Web::IHttpHandler ^ handler, System::IO::TextWriter ^ writer, bool preserveForm);" />
<MemberSignature Language="F#" Value="member this.Execute : System.Web.IHttpHandler * System.IO.TextWriter * bool -&gt; unit" Usage="httpServerUtility.Execute (handler, writer, preserveForm)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="handler" Type="System.Web.IHttpHandler" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="writer" Type="System.IO.TextWriter" Index="1" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="preserveForm" Type="System.Boolean" Index="2" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
</Parameters>
<Docs>
<param name="handler">The HTTP handler that implements the <see cref="T:System.Web.IHttpHandler" /> to transfer the current request to.</param>
<param name="writer">The <see cref="T:System.IO.TextWriter" /> to capture the output.</param>
<param name="preserveForm">
<see langword="true" /> to preserve the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections; <see langword="false" /> to clear the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections.</param>
<summary>Executes the handler for the specified virtual path in the context of the current request. A <see cref="T:System.IO.TextWriter" /> captures output from the executed handler and a Boolean parameter specifies whether to clear the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can write custom HTTP handlers to process specific, predefined types of HTTP requests in any language that is compliant with the Common Language Specification (CLS). Executable code that is defined in the HTTP handler classes instead of conventional ASP (also known as classic ASP) pages or ASP.NET pages responds to these specific requests. HTTP handlers allow for interacting with the low-level request and response services of a Web server that is running Internet Information Services (IIS), and they provide functionality that is similar to ISAPI extensions but with a simpler programming model.
ASP.NET does not verify that the current user is authorized to view the resource that is delivered by the <xref:System.Web.HttpServerUtility.Execute%2A> method. Although the ASP.NET authorization and authentication logic runs before the original resource handler is called, ASP.NET directly calls the handler that is indicated by the <xref:System.Web.HttpServerUtility.Execute%2A> method and does not rerun authentication and authorization logic for the new resource. If the security policy for your application requires clients to have appropriate authorization to gain access to the resource, the application should force reauthorization or provide a custom access-control mechanism.
You can force reauthorization by using the <xref:System.Web.HttpResponse.Redirect%2A> method instead of the <xref:System.Web.HttpServerUtility.Execute%2A> method. The <xref:System.Web.HttpResponse.Redirect%2A> performs a client-side redirect in which the browser requests the new resource. Because this redirect is a new request entering the system, it is subjected to all the authentication and authorization logic of both the IIS and ASP.NET security policy.
You can verify that the user has permission to view the resource by incorporating a custom authorization method that uses the <xref:System.Security.Principal.WindowsPrincipal.IsInRole%2A> method before the application calls the <xref:System.Web.HttpServerUtility.Execute%2A> method.
]]></format>
</remarks>
<exception cref="T:System.Web.HttpException">An error occurred while executing the handler specified by <paramref name="handler" />.</exception>
<exception cref="T:System.ArgumentNullException">The <paramref name="handler" /> parameter is <see langword="null" />.</exception>
<altmember cref="Overload:System.Web.HttpServerUtility.Transfer" />
</Docs>
</Member>
<Member MemberName="GetLastError">
<MemberSignature Language="C#" Value="public Exception GetLastError ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Exception GetLastError() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.GetLastError" />
<MemberSignature Language="VB.NET" Value="Public Function GetLastError () As Exception" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; Exception ^ GetLastError();" />
<MemberSignature Language="F#" Value="member this.GetLastError : unit -&gt; Exception" Usage="httpServerUtility.GetLastError " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Exception</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Returns the previous exception.</summary>
<returns>The previous exception that was thrown.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example prints a description of the application's last error to the HTTP output stream. It prints "No Errors" if no errors have been encountered.
[!code-csharp[Classic HttpServerUtility.GetLastError Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.GetLastError Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.GetLastError Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.GetLastError Example/VB/source.vb#1)]
]]></format>
</remarks>
<altmember cref="M:System.Web.HttpServerUtility.ClearError" />
</Docs>
</Member>
<MemberGroup MemberName="HtmlDecode">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Decodes a string that has been encoded to eliminate invalid HTML characters.
To encode or decode values outside of a web application, use the <see cref="T:System.Net.WebUtility" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName="HtmlDecode">
<MemberSignature Language="C#" Value="public string HtmlDecode (string s);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance string HtmlDecode(string s) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.HtmlDecode(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function HtmlDecode (s As String) As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::String ^ HtmlDecode(System::String ^ s);" />
<MemberSignature Language="F#" Value="member this.HtmlDecode : string -&gt; string" Usage="httpServerUtility.HtmlDecode s" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="s" Type="System.String" />
</Parameters>
<Docs>
<param name="s">The HTML string to decode.</param>
<summary>Decodes an HTML-encoded string and returns the decoded string.</summary>
<returns>The decoded text.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
HTML encoding makes sure that text is displayed correctly in the browser and not interpreted by the browser as HTML. For example, if a text string contains a less than sign (\<) or greater than sign (>), the browser would interpret these characters as the opening or closing bracket of an HTML tag. When the characters are HTML encoded, they are converted to the strings `&lt;` and `&gt;`, which causes the browser to display the less than sign and greater than sign correctly. <xref:System.Web.HttpServerUtility.HtmlDecode%2A> decodes text that has been transmitted to the server.
This method is a convenient way to access the <xref:System.Web.HttpUtility.HtmlDecode%2A?displayProperty=nameWithType> method at run time from an ASP.NET application. Internally, this method uses <xref:System.Web.HttpUtility.HtmlDecode%2A?displayProperty=nameWithType> to decode strings.
In the code-behind file for an ASP.NET web page, access an instance of the <xref:System.Web.HttpServerUtility> class through the `Server` property. In a class that is not in a code-behind file, use `HttpContext.Current.Server` to access an instance of the <xref:System.Web.HttpServerUtility> class.
Outside of a web application, use the <xref:System.Net.WebUtility> class to encode or decode values.
## Examples
The following example contains the function `LoadDecodedFile`, which decodes the data from a file and copies it into one string.
[!code-aspx-csharp[Classic HttpServerUtility.HtmlDecode Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.HtmlDecode Example/CS/sourcecs.aspx#1)]
[!code-aspx-vb[Classic HttpServerUtility.HtmlDecode Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.HtmlDecode Example/VB/sourcevb.aspx#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="HtmlDecode">
<MemberSignature Language="C#" Value="public void HtmlDecode (string s, System.IO.TextWriter output);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void HtmlDecode(string s, class System.IO.TextWriter output) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.HtmlDecode(System.String,System.IO.TextWriter)" />
<MemberSignature Language="VB.NET" Value="Public Sub HtmlDecode (s As String, output As TextWriter)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void HtmlDecode(System::String ^ s, System::IO::TextWriter ^ output);" />
<MemberSignature Language="F#" Value="member this.HtmlDecode : string * System.IO.TextWriter -&gt; unit" Usage="httpServerUtility.HtmlDecode (s, output)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="s" Type="System.String" />
<Parameter Name="output" Type="System.IO.TextWriter" />
</Parameters>
<Docs>
<param name="s">The HTML string to decode.</param>
<param name="output">The <see cref="T:System.IO.TextWriter" /> output stream that contains the decoded string.</param>
<summary>Decodes an HTML-encoded string and sends the resulting output to a <see cref="T:System.IO.TextWriter" /> output stream.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
HTML encoding makes sure that text is displayed correctly in the browser and not interpreted by the browser as HTML. For example, if a text string contains a less than sign (\<) or greater than sign (>), the browser would interpret these characters as the opening or closing bracket of an HTML tag. When the characters are HTML encoded, they are converted to the strings `&lt;` and `&gt;`, which causes the browser to display the less than sign and greater than sign correctly.
<xref:System.Web.HttpServerUtility.HtmlDecode%2A> decodes text that has been transmitted to the server.
<xref:System.Web.HttpServerUtility.HtmlDecode%2A> is a convenient way to access the <xref:System.Web.HttpUtility.HtmlDecode%2A?displayProperty=nameWithType> method at run time from an ASP.NET application. Internally, <xref:System.Web.HttpServerUtility.HtmlDecode%2A> uses <xref:System.Web.HttpUtility.HtmlDecode%2A?displayProperty=nameWithType> to decode strings.
To encode or decode values outside of a web application, use the <xref:System.Net.WebUtility> class.
## Examples
The following example decodes a string that has been HTML-encoded for transmission over HTTP. It decodes the supplied string named `EncodedString` which contains the text "This is a &lt;Test String&gt;.", and copies it into the string named `DecodedString` as "This is a \<Test String>.".
[!code-csharp[Classic HttpServerUtility.HtmlDecode1 Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.HtmlDecode1 Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.HtmlDecode1 Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.HtmlDecode1 Example/VB/source.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<MemberGroup MemberName="HtmlEncode">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Encodes a string to be displayed in a browser.
To encode or decode values outside of a web application, use the <see cref="T:System.Net.WebUtility" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName="HtmlEncode">
<MemberSignature Language="C#" Value="public string HtmlEncode (string s);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance string HtmlEncode(string s) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.HtmlEncode(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function HtmlEncode (s As String) As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::String ^ HtmlEncode(System::String ^ s);" />
<MemberSignature Language="F#" Value="member this.HtmlEncode : string -&gt; string" Usage="httpServerUtility.HtmlEncode s" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="s" Type="System.String" />
</Parameters>
<Docs>
<param name="s">The text string to encode.</param>
<summary>HTML-encodes a string and returns the encoded string.</summary>
<returns>The HTML-encoded text.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
HTML encoding makes sure that text is displayed correctly in the browser and not interpreted by the browser as HTML. For example, if a text string contains a less than sign (\<) or greater than sign (>), the browser would interpret these characters as the opening or closing bracket of an HTML tag. When the characters are HTML encoded, they are converted to the strings `&lt;` and `&gt;`, which causes the browser to display the less than sign and greater than sign correctly.
This method is a convenient way to access the <xref:System.Web.HttpUtility.HtmlEncode%2A?displayProperty=nameWithType> method at run time from an ASP.NET application. Internally, this method uses <xref:System.Web.HttpUtility.HtmlEncode%2A?displayProperty=nameWithType> to encode strings.
In the code-behind file for an ASP.NET web page, access an instance of the <xref:System.Web.HttpServerUtility> class through the `Server` property. In a class that is not in a code-behind file, use `HttpContext.Current.Server` to access an instance of the <xref:System.Web.HttpServerUtility> class.
Outside of a web application, use the <xref:System.Net.WebUtility> class to encode or decode values.
## Examples
The following example shows how to HTML-encode a value that potentially codes unsafe code. The code resides in the code-behind file for a web page. The value to encode is hard-coded in this example only to simplify the example and show the type of value you might HTML-encode. Typically, you would HTML-encode a value that you received from the user or the request. `Result` refers to a `Literal` control.
[!code-csharp[System.Web.HttpServerUtility.HtmlEncode#1](~/samples/snippets/csharp/VS_Snippets_WebNet/system.web.httpserverutility.htmlencode/cs/default.aspx.cs#1)]
[!code-vb[System.Web.HttpServerUtility.HtmlEncode#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/system.web.httpserverutility.htmlencode/vb/default.aspx.vb#1)]
The next example is similar to the previous example except it shows how to HTML-encode a value from within a class that is not in the code-behind file.
[!code-csharp[System.Web.HttpServerUtility.HtmlEncode#2](~/samples/snippets/csharp/VS_Snippets_WebNet/system.web.httpserverutility.htmlencode/cs/sampleclass.cs#2)]
[!code-vb[System.Web.HttpServerUtility.HtmlEncode#2](~/samples/snippets/visualbasic/VS_Snippets_WebNet/system.web.httpserverutility.htmlencode/vb/sampleclass.vb#2)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="HtmlEncode">
<MemberSignature Language="C#" Value="public void HtmlEncode (string s, System.IO.TextWriter output);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void HtmlEncode(string s, class System.IO.TextWriter output) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.HtmlEncode(System.String,System.IO.TextWriter)" />
<MemberSignature Language="VB.NET" Value="Public Sub HtmlEncode (s As String, output As TextWriter)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void HtmlEncode(System::String ^ s, System::IO::TextWriter ^ output);" />
<MemberSignature Language="F#" Value="member this.HtmlEncode : string * System.IO.TextWriter -&gt; unit" Usage="httpServerUtility.HtmlEncode (s, output)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="s" Type="System.String" />
<Parameter Name="output" Type="System.IO.TextWriter" />
</Parameters>
<Docs>
<param name="s">The string to encode.</param>
<param name="output">The <see cref="T:System.IO.TextWriter" /> output stream that contains the encoded string.</param>
<summary>HTML-encodes a string and sends the resulting output to a <see cref="T:System.IO.TextWriter" /> output stream.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
HTML encoding ensures that text will be correctly displayed in the browser, not interpreted by the browser as HTML. For example, if a text string contains a less than sign (\<) or greater than sign (>), the browser would interpret these characters as an opening or closing bracket of an HTML tag. The HTML encoding of these two characters is `&lt;` and `&gt;`, respectively, which causes the browser to display the less than sign and greater than sign correctly.
<xref:System.Web.HttpServerUtility.HtmlEncode%2A> is a convenient way to access the <xref:System.Web.HttpUtility.HtmlEncode%2A?displayProperty=nameWithType> method at run time from an ASP.NET application. Internally, <xref:System.Web.HttpServerUtility.HtmlEncode%2A> uses <xref:System.Web.HttpUtility.HtmlEncode%2A?displayProperty=nameWithType> to encode strings.
To encode or decode values outside of a web application, use the <xref:System.Net.WebUtility> class.
## Examples
The following example encodes a string for transmission by HTTP. It encodes the string named `TestString`, which contains the text "This is a \<Test String>.", and copies it into the string named `EncodedString` as "This is a &lt;Test String&gt;.".
[!code-csharp[Classic HttpServerUtility.HtmlEncode1 Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.HtmlEncode1 Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.HtmlEncode1 Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.HtmlEncode1 Example/VB/source.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="MachineName">
<MemberSignature Language="C#" Value="public string MachineName { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string MachineName" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpServerUtility.MachineName" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property MachineName As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::String ^ MachineName { System::String ^ get(); };" />
<MemberSignature Language="F#" Value="member this.MachineName : string" Usage="System.Web.HttpServerUtility.MachineName" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the server's computer name.</summary>
<value>The name of the local computer.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example stores the server's computer name as a string variable.
[!code-csharp[Classic HttpServerUtility.MachineName Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.MachineName Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.MachineName Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.MachineName Example/VB/source.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.Web.HttpException">The computer name cannot be found.</exception>
</Docs>
</Member>
<Member MemberName="MapPath">
<MemberSignature Language="C#" Value="public string MapPath (string path);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance string MapPath(string path) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.MapPath(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function MapPath (path As String) As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::String ^ MapPath(System::String ^ path);" />
<MemberSignature Language="F#" Value="member this.MapPath : string -&gt; string" Usage="httpServerUtility.MapPath path" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<param name="path">The virtual path in the Web application.</param>
<summary>Returns the physical file path that corresponds to the specified virtual path.</summary>
<returns>The physical file path on the Web server that corresponds to <paramref name="path" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If `path` is `null`, the <xref:System.Web.HttpServerUtility.MapPath%2A> method returns the full physical path of the directory that contains the current request for the path. The relative path does not need to specify an existing file or folder for this method to return a value. However, you cannot specify a path outside of the Web application.
> [!IMPORTANT]
> The <xref:System.Web.HttpServerUtility.MapPath%2A> method potentially contains sensitive information about the hosting environment. The return value should not be displayed to users.
A Web application that resides at `C:\ExampleSites\TestMapPath` would return the following results:
|Request from|`path`|Returned value|
|------------------|------------|--------------------|
|RootLevelPage.aspx|`null`|C:\ExampleSites\TestMapPath|
|RootLevelPage.aspx|"/DownOneLevel/DownLevelPage.aspx"|C:\ExampleSites\TestMapPath\DownOneLevel\DownLevelPage.aspx|
|RootLevelPage.aspx|"/NotRealFolder"|C:\ExampleSites\TestMapPath\NotRealFolder|
|RootLevelPage.aspx|"../OutsideApplication"|<xref:System.Web.HttpException>|
|/DownOneLevel/DownLevelPage.aspx|`null`|C:\ExampleSites\TestMapPath\DownOneLevel|
|/DownOneLevel/DownLevelPage.aspx|"../RootLevelPage.aspx"|C:\ExampleSites\TestMapPath\RootLevelPage.aspx|
## Examples
The following example shows how to retrieve the physical file of a relative virtual path. The code resides in the code-behind file for a web page and utilizes the default `Server` object.
[!code-csharp[System.Web.HttpServerUtility.MapPath#1](~/samples/snippets/csharp/VS_Snippets_WebNet/system.web.httpserverutility.mappath/cs/default.aspx.cs#1)]
[!code-vb[System.Web.HttpServerUtility.MapPath#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/system.web.httpserverutility.mappath/vb/default.aspx.vb#1)]
The next example is similar to the previous example except it shows how to retrieve a physical path from within a class that is not in the code-behind file.
[!code-csharp[System.Web.HttpServerUtility.MapPath#2](~/samples/snippets/csharp/VS_Snippets_WebNet/system.web.httpserverutility.mappath/cs/sampleclass.cs#2)]
[!code-vb[System.Web.HttpServerUtility.MapPath#2](~/samples/snippets/visualbasic/VS_Snippets_WebNet/system.web.httpserverutility.mappath/vb/sampleclass.vb#2)]
]]></format>
</remarks>
<exception cref="T:System.Web.HttpException">The current <see cref="T:System.Web.HttpContext" /> is <see langword="null" />.
-or-
<paramref name="path" /> is a physical path, but a virtual path was expected.</exception>
</Docs>
</Member>
<Member MemberName="ScriptTimeout">
<MemberSignature Language="C#" Value="public int ScriptTimeout { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 ScriptTimeout" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpServerUtility.ScriptTimeout" />
<MemberSignature Language="VB.NET" Value="Public Property ScriptTimeout As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property int ScriptTimeout { int get(); void set(int value); };" />
<MemberSignature Language="F#" Value="member this.ScriptTimeout : int with get, set" Usage="System.Web.HttpServerUtility.ScriptTimeout" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the request time-out value in seconds.</summary>
<value>The time-out value setting for requests.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.HttpServerUtility.ScriptTimeout%2A> property can be set in the Web.config file by setting the `executionTimeout` attribute of the [httpRuntime](https://msdn.microsoft.com/library/e9b81350-8aaf-47cc-9843-5f7d0c59f369) element. Setting the time-out programmatically with the <xref:System.Web.HttpServerUtility.ScriptTimeout%2A> property takes precedence over the Web.config setting.
> [!NOTE]
> If you set the `debug` attribute of the [httpRuntime](https://msdn.microsoft.com/library/e9b81350-8aaf-47cc-9843-5f7d0c59f369) element to `true` in the Web.config file, the value of <xref:System.Web.HttpServerUtility.ScriptTimeout%2A> will be ignored.
## Examples
The following example sets the request time-out period to 60 seconds.
[!code-csharp[Classic HttpServerUtility.ScriptTimeout Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.ScriptTimeout Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.ScriptTimeout Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.ScriptTimeout Example/VB/source.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.Web.HttpException">The current <see cref="T:System.Web.HttpContext" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">The time-out period is <see langword="null" /> or otherwise could not be set.</exception>
</Docs>
</Member>
<MemberGroup MemberName="Transfer">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Terminates execution of the current page and starts execution of a new page for the current request.</summary>
</Docs>
</MemberGroup>
<Member MemberName="Transfer">
<MemberSignature Language="C#" Value="public void Transfer (string path);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Transfer(string path) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.Transfer(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub Transfer (path As String)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void Transfer(System::String ^ path);" />
<MemberSignature Language="F#" Value="member this.Transfer : string -&gt; unit" Usage="httpServerUtility.Transfer path" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<param name="path">The URL path of the new page on the server to execute.</param>
<summary>For the current request, terminates execution of the current page and starts execution of a new page by using the specified URL path of the page.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The page transferred to should be another .aspx page. For instance, a transfer to an .asp or .asmx page is not valid. The <xref:System.Web.HttpServerUtility.Transfer%2A> method preserves the <xref:System.Web.HttpRequest.QueryString%2A> and <xref:System.Web.HttpRequest.Form%2A> collections.
<xref:System.Web.HttpServerUtility.Transfer%2A> calls <xref:System.Web.HttpResponse.End%2A>, which throws a <xref:System.Threading.ThreadAbortException> exception upon completion.
ASP.NET does not verify that the current user is authorized to view the resource delivered by the <xref:System.Web.HttpServerUtility.Transfer%2A> method. Although the ASP.NET authorization and authentication logic runs before the original resource handler is called, ASP.NET directly calls the handler indicated by the <xref:System.Web.HttpServerUtility.Transfer%2A> method and does not rerun authentication and authorization logic for the new resource. If your application's security policy requires clients to have appropriate authorization to access the resource, the application should force reauthorization or provide a custom access-control mechanism.
You can force reauthorization by using the <xref:System.Web.HttpResponse.Redirect%2A> method instead of the <xref:System.Web.HttpServerUtility.Transfer%2A> method. The <xref:System.Web.HttpResponse.Redirect%2A> method performs a client-side redirect in which the browser requests the new resource. Because this redirect is a new request entering the system, it is subjected to all the authentication and authorization logic of both Internet Information Services (IIS) and ASP.NET security policy.
You can verify that the user has permission to view the resource by incorporating a custom authorization method that uses the <xref:System.Security.Principal.WindowsPrincipal.IsInRole%2A> method before the application calls the <xref:System.Web.HttpServerUtility.Transfer%2A> method.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Transfer">
<MemberSignature Language="C#" Value="public void Transfer (string path, bool preserveForm);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Transfer(string path, bool preserveForm) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.Transfer(System.String,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub Transfer (path As String, preserveForm As Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void Transfer(System::String ^ path, bool preserveForm);" />
<MemberSignature Language="F#" Value="member this.Transfer : string * bool -&gt; unit" Usage="httpServerUtility.Transfer (path, preserveForm)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
<Parameter Name="preserveForm" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="path">The URL path of the new page on the server to execute.</param>
<param name="preserveForm">
<see langword="true" /> to preserve the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections; <see langword="false" /> to clear the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections.</param>
<summary>Terminates execution of the current page and starts execution of a new page by using the specified URL path of the page. Specifies whether to clear the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The page transferred to should be another .aspx page. For instance, a transfer to an .asp or .asmx page is not valid.
<xref:System.Web.HttpServerUtility.Transfer%2A> calls <xref:System.Web.HttpResponse.End%2A>, which throws a <xref:System.Threading.ThreadAbortException> exception upon completion.
If you set the `preserveForm` parameter to `true`, the target page will be able to access the view state of the previous page by using the <xref:System.Web.UI.Page.PreviousPage%2A> property.
For security purposes, you should keep the `enableViewStateMac` attribute set to `true`. ASP.NET does not verify that the current user is authorized to view the resource delivered by the <xref:System.Web.HttpServerUtility.Transfer%2A> method. Although the ASP.NET authorization and authentication logic runs before the original resource handler is called, ASP.NET directly calls the handler indicated by the <xref:System.Web.HttpServerUtility.Transfer%2A> method and does not rerun authentication and authorization logic for the new resource. If your application's security policy requires clients to have appropriate authorization to access the resource, the application should force reauthorization or provide a custom access-control mechanism.
You can force reauthorization by using the <xref:System.Web.HttpResponse.Redirect%2A> method instead of the <xref:System.Web.HttpServerUtility.Transfer%2A> method. The <xref:System.Web.HttpResponse.Redirect%2A> method performs a client-side redirect in which the browser requests the new resource. Because this redirect is a new request entering the system, it is subjected to all the authentication and authorization logic of both Internet Information Services (IIS) and ASP.NET security policy.
You can verify that the user has permission to view the resource by incorporating a custom authorization method that uses the <xref:System.Security.Principal.WindowsPrincipal.IsInRole%2A> method before the application calls the <xref:System.Web.HttpServerUtility.Transfer%2A> method.
## Examples
The following example executes a new page in the same directory as the current page.
[!code-csharp[Classic HttpServerUtility.Transfer Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.Transfer Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.Transfer Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.Transfer Example/VB/source.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.ApplicationException">The current page request is a callback.</exception>
</Docs>
</Member>
<Member MemberName="Transfer">
<MemberSignature Language="C#" Value="public void Transfer (System.Web.IHttpHandler handler, bool preserveForm);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Transfer(class System.Web.IHttpHandler handler, bool preserveForm) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.Transfer(System.Web.IHttpHandler,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub Transfer (handler As IHttpHandler, preserveForm As Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void Transfer(System::Web::IHttpHandler ^ handler, bool preserveForm);" />
<MemberSignature Language="F#" Value="member this.Transfer : System.Web.IHttpHandler * bool -&gt; unit" Usage="httpServerUtility.Transfer (handler, preserveForm)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="handler" Type="System.Web.IHttpHandler" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="preserveForm" Type="System.Boolean" Index="1" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
</Parameters>
<Docs>
<param name="handler">The HTTP handler that implements the <see cref="T:System.Web.IHttpHandler" /> to transfer the current request to.</param>
<param name="preserveForm">
<see langword="true" /> to preserve the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections; <see langword="false" /> to clear the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections.</param>
<summary>Terminates execution of the current page and starts execution of a new request by using a custom HTTP handler that implements the <see cref="T:System.Web.IHttpHandler" /> interface and specifies whether to clear the <see cref="P:System.Web.HttpRequest.QueryString" /> and <see cref="P:System.Web.HttpRequest.Form" /> collections.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can write custom HTTP handlers to process specific, predefined types of HTTP requests in any language that is compliant with the Common Language Specification (CLS). Executable code that is defined in the HTTP handler classes instead of conventional ASP (also known as classic ASP) pages or ASP.NET pages responds to these specific requests. HTTP handlers allow for interacting with the low-level request and response services of a Web server that is running Internet Information Services (IIS), and they provide functionality that is similar to ISAPI extensions but with a simpler programming model.
If you set the `preserveForm` parameter to `true`, the target page will be able to access the view state of the previous page by using the <xref:System.Web.UI.Page.PreviousPage%2A> property.
For security purposes, you should keep the `enableViewStateMac` attribute set to `true`. ASP.NET does not verify that the current user is authorized to view the resource delivered by the <xref:System.Web.HttpServerUtility.Transfer%2A> method. Although the ASP.NET authorization and authentication logic runs before the original resource handler is called, ASP.NET directly calls the handler indicated by the <xref:System.Web.HttpServerUtility.Transfer%2A> method, and does not rerun authentication and authorization logic for the new resource. If the security policy for your application requires clients to have appropriate authorization to access the resource, the application should force reauthorization or provide a custom access-control mechanism.
You can force reauthorization by using the <xref:System.Web.HttpResponse.Redirect%2A> method instead of the <xref:System.Web.HttpServerUtility.Transfer%2A> method. The <xref:System.Web.HttpResponse.Redirect%2A> method performs a client-side redirect in which the browser requests the new resource. Because this redirect is a new request entering the system, it is subjected to all the authentication and authorization logic of both the IIS and ASP.NET security policy.
You can verify that the user has permission to view the resource by incorporating a custom authorization method that uses the <xref:System.Security.Principal.WindowsPrincipal.IsInRole%2A> method before the application calls the <xref:System.Web.HttpServerUtility.Transfer%2A> method.
]]></format>
</remarks>
<exception cref="T:System.ApplicationException">The current page request is a callback.</exception>
</Docs>
</Member>
<MemberGroup MemberName="TransferRequest">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Performs an asynchronous execution of the specified URL.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Web.HttpServerUtility.TransferRequest%2A> was introduced in the .NET Framework version 3.5. For summary information about the .NET Framework, see [Versions and Dependencies](~/docs/framework/migration-guide/versions-and-dependencies.md).
]]></format>
</remarks>
</Docs>
</MemberGroup>
<Member MemberName="TransferRequest">
<MemberSignature Language="C#" Value="public void TransferRequest (string path);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void TransferRequest(string path) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.TransferRequest(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub TransferRequest (path As String)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void TransferRequest(System::String ^ path);" />
<MemberSignature Language="F#" Value="member this.TransferRequest : string -&gt; unit" Usage="httpServerUtility.TransferRequest path" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
</Parameters>
<Docs>
<param name="path">The URL path of the new page on the server to execute.</param>
<summary>Performs an asynchronous execution of the specified URL.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method overload calls the <xref:System.Web.HttpServerUtility.TransferRequest%2A> overload with the `preserveForm` parameter set to `false`, the `method` parameter set to `null`, the `headers` parameter set to `null`, and the `preserveUser` parameter set to `true`. For more information, see the "Remarks" section in <xref:System.Web.HttpServerUtility.TransferRequest%28System.String%2CSystem.Boolean%2CSystem.String%2CSystem.Collections.Specialized.NameValueCollection%29> overload.
]]></format>
</remarks>
<exception cref="T:System.PlatformNotSupportedException">The request requires the integrated pipeline mode of [!INCLUDE[iisver](~/includes/iisver-md.md)].</exception>
<exception cref="T:System.Web.HttpException">The server is not available to handle the request.</exception>
<exception cref="T:System.ArgumentNullException">The <paramref name="path" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The <paramref name="path" /> parameter is invalid.</exception>
</Docs>
</Member>
<Member MemberName="TransferRequest">
<MemberSignature Language="C#" Value="public void TransferRequest (string path, bool preserveForm);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void TransferRequest(string path, bool preserveForm) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.TransferRequest(System.String,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub TransferRequest (path As String, preserveForm As Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void TransferRequest(System::String ^ path, bool preserveForm);" />
<MemberSignature Language="F#" Value="member this.TransferRequest : string * bool -&gt; unit" Usage="httpServerUtility.TransferRequest (path, preserveForm)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="preserveForm" Type="System.Boolean" Index="1" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
</Parameters>
<Docs>
<param name="path">The URL path of the new page on the server to execute.</param>
<param name="preserveForm">
<see langword="true" /> to preserve the <see cref="P:System.Web.HttpRequest.Form" /> collection; <see langword="false" /> to clear the <see cref="P:System.Web.HttpRequest.Form" /> collection.</param>
<summary>Performs an asynchronous execution of the specified URL and preserves query string parameters.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This overload calls the <xref:System.Web.HttpServerUtility.TransferRequest%2A> overload with the `preserveForm` parameter set to the value passed in, the `method` parameter set to `null`, the `headers` parameter set to `null`, and the `preserveUser` parameter set to `true`. For more information, see the "Remarks" section in <xref:System.Web.HttpServerUtility.TransferRequest%28System.String%2CSystem.Boolean%2CSystem.String%2CSystem.Collections.Specialized.NameValueCollection%29>.
<xref:System.Web.HttpServerUtility.TransferRequest%2A> is introduced in the .NET Framework version 3.5. For more information, see [Versions and Dependencies](~/docs/framework/migration-guide/versions-and-dependencies.md).
]]></format>
</remarks>
<exception cref="T:System.PlatformNotSupportedException">The request requires the integrated pipeline mode of [!INCLUDE[iisver](~/includes/iisver-md.md)].</exception>
<exception cref="T:System.Web.HttpException">The server is not available to handle the request.</exception>
<exception cref="T:System.ArgumentNullException">The <paramref name="path" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The <paramref name="path" /> parameter is invalid.</exception>
</Docs>
</Member>
<Member MemberName="TransferRequest">
<MemberSignature Language="C#" Value="public void TransferRequest (string path, bool preserveForm, string method, System.Collections.Specialized.NameValueCollection headers);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void TransferRequest(string path, bool preserveForm, string method, class System.Collections.Specialized.NameValueCollection headers) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.TransferRequest(System.String,System.Boolean,System.String,System.Collections.Specialized.NameValueCollection)" />
<MemberSignature Language="VB.NET" Value="Public Sub TransferRequest (path As String, preserveForm As Boolean, method As String, headers As NameValueCollection)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void TransferRequest(System::String ^ path, bool preserveForm, System::String ^ method, System::Collections::Specialized::NameValueCollection ^ headers);" />
<MemberSignature Language="F#" Value="member this.TransferRequest : string * bool * string * System.Collections.Specialized.NameValueCollection -&gt; unit" Usage="httpServerUtility.TransferRequest (path, preserveForm, method, headers)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="preserveForm" Type="System.Boolean" Index="1" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="method" Type="System.String" Index="2" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="headers" Type="System.Collections.Specialized.NameValueCollection" Index="3" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
</Parameters>
<Docs>
<param name="path">The URL path of the new page on the server to execute.</param>
<param name="preserveForm">
<see langword="true" /> to preserve the <see cref="P:System.Web.HttpRequest.Form" /> collection; <see langword="false" /> to clear the <see cref="P:System.Web.HttpRequest.Form" /> collection.</param>
<param name="method">The HTTP method to use in the execution of the new request.</param>
<param name="headers">A <see cref="T:System.Collections.Specialized.NameValueCollection" /> of request headers for the new request.</param>
<summary>Performs an asynchronous execution of the specified URL using the specified HTTP method and headers.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method is used when running with the integrated pipeline mode in [!INCLUDE[iisver](~/includes/iisver-md.md)] to allow request processing to be transferred from one resource type to another while executing the target request with the correct request context. For example, you can use the <xref:System.Web.HttpServerUtility.TransferRequest%2A> method to transfer a request for an ASPX page to a request for an XML page.
The <xref:System.Web.HttpServerUtility.TransferRequest%2A> method performs an asynchronous child execution of the specified URL with the following conditions:
- If the `path` parameter specifies a query string, it will be used as the new query string. If no query string is included, the query string of the request will be re-used.
- If the `method` parameter is specified, it will be used. If it is `null`, the HTTP method of the original request will be used.
- If the `preserveForm` parameter is `true`, the current entity body of the request will be available to the target request. This allows form posts and uploads to be transferred.
- If the user identity is currently set on the original request, the identity will be transferred to the new request. This allows authenticated requests to re-use the result of the authentication for the new request. If you do not want the user to be transferred, set the user to `null` on the original request before transferring.
- If the `headers` parameter is specified, the new request will execute with the specified headers. This can be used to modify the request headers and cookies for the new request, or add a special header that specifies where the original request was received.
This method calls the <xref:System.Web.HttpServerUtility.TransferRequest%28System.String%2CSystem.Boolean%2CSystem.String%2CSystem.Collections.Specialized.NameValueCollection%2CSystem.Boolean%29> method overload with the `preserveUser` parameter set to `true`.
]]></format>
</remarks>
<exception cref="T:System.PlatformNotSupportedException">The request requires [!INCLUDE[iisver](~/includes/iisver-md.md)] running in integrated mode.</exception>
<exception cref="T:System.Web.HttpException">The server is not available to handle the request.</exception>
<exception cref="T:System.ArgumentNullException">The <paramref name="path" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The <paramref name="path" /> parameter is invalid.</exception>
</Docs>
</Member>
<Member MemberName="TransferRequest">
<MemberSignature Language="C#" Value="public void TransferRequest (string path, bool preserveForm, string method, System.Collections.Specialized.NameValueCollection headers, bool preserveUser);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void TransferRequest(string path, bool preserveForm, string method, class System.Collections.Specialized.NameValueCollection headers, bool preserveUser) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.TransferRequest(System.String,System.Boolean,System.String,System.Collections.Specialized.NameValueCollection,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub TransferRequest (path As String, preserveForm As Boolean, method As String, headers As NameValueCollection, preserveUser As Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void TransferRequest(System::String ^ path, bool preserveForm, System::String ^ method, System::Collections::Specialized::NameValueCollection ^ headers, bool preserveUser);" />
<MemberSignature Language="F#" Value="member this.TransferRequest : string * bool * string * System.Collections.Specialized.NameValueCollection * bool -&gt; unit" Usage="httpServerUtility.TransferRequest (path, preserveForm, method, headers, preserveUser)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" Index="0" FrameworkAlternate="netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="preserveForm" Type="System.Boolean" Index="1" FrameworkAlternate="netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="method" Type="System.String" Index="2" FrameworkAlternate="netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="headers" Type="System.Collections.Specialized.NameValueCollection" Index="3" FrameworkAlternate="netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
<Parameter Name="preserveUser" Type="System.Boolean" Index="4" FrameworkAlternate="netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
</Parameters>
<Docs>
<param name="path">The path.</param>
<param name="preserveForm">
<see langword="true" /> to preserve the <see cref="P:System.Web.HttpRequest.Form" /> collection; <see langword="false" /> to clear the <see cref="P:System.Web.HttpRequest.Form" /> collection.</param>
<param name="method">The HTTP method to use in the new request.</param>
<param name="headers">A <see cref="T:System.Collections.Specialized.NameValueCollection" /> object that contains request headers for the new request.</param>
<param name="preserveUser">
<see langword="true" /> to preserve the user identity; otherwise, <see langword="false" />. The other method overloads of this method call this overload with this parameter set to <see langword="true" />.</param>
<summary>Performs an asynchronous execution of the specified URL using the specified HTTP method, headers, and path, and optionally preserves form values and the user identity.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
For more information, see the "Remarks" section in <xref:System.Web.HttpServerUtility.TransferRequest%28System.String%2CSystem.Boolean%2CSystem.String%2CSystem.Collections.Specialized.NameValueCollection%29>.
]]></format>
</remarks>
<exception cref="T:System.PlatformNotSupportedException">The request requires the integrated pipeline mode of [!INCLUDE[iisver](~/includes/iisver-md.md)].</exception>
<exception cref="T:System.Web.HttpException">The server is not available to handle the request.</exception>
<exception cref="T:System.ArgumentNullException">The <paramref name="path" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The <paramref name="path" /> parameter is invalid.</exception>
</Docs>
</Member>
<MemberGroup MemberName="UrlDecode">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Decodes a string that was encoded for HTTP transmission and then sent to the server in a URL.
To encode or decode values outside of a web application, use the <see cref="T:System.Net.WebUtility" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName="UrlDecode">
<MemberSignature Language="C#" Value="public string UrlDecode (string s);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance string UrlDecode(string s) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.UrlDecode(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function UrlDecode (s As String) As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::String ^ UrlDecode(System::String ^ s);" />
<MemberSignature Language="F#" Value="member this.UrlDecode : string -&gt; string" Usage="httpServerUtility.UrlDecode s" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="s" Type="System.String" />
</Parameters>
<Docs>
<param name="s">The text string to decode.</param>
<summary>URL-decodes a string and returns the decoded string.</summary>
<returns>The decoded text.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
URL encoding ensures that all browsers will correctly transmit text in URL strings. Characters such as a question mark (?), ampersand (&), slash mark (/), and spaces might be truncated or corrupted by some browsers. As a result, these characters must be encoded in `<a>` tags or in query strings where the strings can be re-sent by a browser in a request string.
This method is a convenient way to access the <xref:System.Web.HttpUtility.UrlDecode%2A?displayProperty=nameWithType> method at run time from an ASP.NET application. Internally, this method uses <xref:System.Web.HttpUtility.UrlDecode%2A?displayProperty=nameWithType> to decode strings.
In the code-behind file for an ASP.NET web page, access an instance of the <xref:System.Web.HttpServerUtility> class through the `Server` property. In a class that is not in a code-behind file, use `HttpContext.Current.Server` to access an instance of the <xref:System.Web.HttpServerUtility> class.
Outside of a web application, use the <xref:System.Net.WebUtility> class to encode or decode values.
## Examples
The following example shows how to URL-decode a value that is retrieved from the query string. The code resides in the code-behind file for a web page. `ReturnPage` refers to a `HyperLink` control.
[!code-csharp[System.Web.HttpServerUtility.UrlDecode#1](~/samples/snippets/csharp/VS_Snippets_WebNet/system.web.httpserverutility.urldecode/cs/default.aspx.cs#1)]
[!code-vb[System.Web.HttpServerUtility.UrlDecode#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/system.web.httpserverutility.urldecode/vb/default.aspx.vb#1)]
The next example is similar to the previous example except it shows how to URL-decode a value from within a class that is not in the code-behind file.
[!code-csharp[System.Web.HttpServerUtility.UrlDecode#2](~/samples/snippets/csharp/VS_Snippets_WebNet/system.web.httpserverutility.urldecode/cs/sampleclass.cs#2)]
[!code-vb[System.Web.HttpServerUtility.UrlDecode#2](~/samples/snippets/visualbasic/VS_Snippets_WebNet/system.web.httpserverutility.urldecode/vb/sampleclass.vb#2)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="UrlDecode">
<MemberSignature Language="C#" Value="public void UrlDecode (string s, System.IO.TextWriter output);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void UrlDecode(string s, class System.IO.TextWriter output) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.UrlDecode(System.String,System.IO.TextWriter)" />
<MemberSignature Language="VB.NET" Value="Public Sub UrlDecode (s As String, output As TextWriter)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void UrlDecode(System::String ^ s, System::IO::TextWriter ^ output);" />
<MemberSignature Language="F#" Value="member this.UrlDecode : string * System.IO.TextWriter -&gt; unit" Usage="httpServerUtility.UrlDecode (s, output)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="s" Type="System.String" />
<Parameter Name="output" Type="System.IO.TextWriter" />
</Parameters>
<Docs>
<param name="s">The HTML string to decode.</param>
<param name="output">The <see cref="T:System.IO.TextWriter" /> output stream that contains the decoded string.</param>
<summary>Decodes an HTML string received in a URL and sends the resulting output to a <see cref="T:System.IO.TextWriter" /> output stream.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
URL encoding ensures that all browsers will correctly transmit text in URL strings. Characters such as a question mark (?), ampersand (&), slash mark (/), and spaces might be truncated or corrupted by some browsers. As a result, these characters must be encoded in `<a>` tags or in query strings where the strings can be re-sent by a browser in a request string.
<xref:System.Web.HttpServerUtility.UrlDecode%2A> is a convenient way to access the <xref:System.Web.HttpUtility.UrlDecode%2A?displayProperty=nameWithType> method at run time from an ASP.NET application. Internally, <xref:System.Web.HttpServerUtility.UrlDecode%2A> uses <xref:System.Web.HttpUtility.UrlDecode%2A?displayProperty=nameWithType> to decode strings.
To encode or decode values outside of a web application, use the <xref:System.Net.WebUtility> class.
## Examples
The following example decodes the string named `EncodedString` (received in a URL) into the string named `DecodedString`.
[!code-csharp[Classic HttpServerUtility.UrlDecode1 Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.UrlDecode1 Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.UrlDecode1 Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.UrlDecode1 Example/VB/source.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<MemberGroup MemberName="UrlEncode">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Encodes a string for reliable HTTP transmission from the Web server to a client through the URL.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Web.HttpServerUtility.UrlEncode%2A> is a convenient way to access the <xref:System.Web.HttpUtility.UrlEncode%2A?displayProperty=nameWithType> method at run time from an ASP.NET application. Internally, <xref:System.Web.HttpServerUtility.UrlEncode%2A> uses <xref:System.Web.HttpUtility.UrlEncode%2A?displayProperty=nameWithType> to encode strings.
To encode or decode values outside of a web application, use the <xref:System.Net.WebUtility> class.
]]></format>
</remarks>
</Docs>
</MemberGroup>
<Member MemberName="UrlEncode">
<MemberSignature Language="C#" Value="public string UrlEncode (string s);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance string UrlEncode(string s) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.UrlEncode(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function UrlEncode (s As String) As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::String ^ UrlEncode(System::String ^ s);" />
<MemberSignature Language="F#" Value="member this.UrlEncode : string -&gt; string" Usage="httpServerUtility.UrlEncode s" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="s" Type="System.String" />
</Parameters>
<Docs>
<param name="s">The text to URL-encode.</param>
<summary>URL-encodes a string and returns the encoded string.</summary>
<returns>The URL-encoded text.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
URL encoding ensures that all browsers will correctly transmit text in URL strings. Characters such as a question mark (?), ampersand (&), slash mark (/), and spaces might be truncated or corrupted by some browsers. As a result, these characters must be encoded in `<a>` tags or in query strings where the strings can be re-sent by a browser in a request string.
This method is a convenient way to access the <xref:System.Web.HttpUtility.UrlEncode%2A?displayProperty=nameWithType> method at run time from an ASP.NET application. Internally, this method uses <xref:System.Web.HttpUtility.UrlEncode%2A?displayProperty=nameWithType> to encode strings.
In the code-behind file for an ASP.NET web page, access an instance of the <xref:System.Web.HttpServerUtility> class through the `Server` property. In a class that is not in a code-behind file, use `HttpContext.Current.Server` to access an instance of the <xref:System.Web.HttpServerUtility> class.
Outside of a web application, use the <xref:System.Net.WebUtility> class to encode or decode values.
## Examples
The following example shows how to URL-encode a value that is used as a query string value of a hyperlink. The code resides in the code-behind file for a web page. The value to encode is hard-coded in this example only to simplify the example and show the type of value you might URL-encode. Typically, you would URL-encode a value that you received from the user or the request. `NextPage` refers to a `HyperLink` control.
[!code-csharp[System.Web.HttpServerUtility.UrlEncode#1](~/samples/snippets/csharp/VS_Snippets_WebNet/system.web.httpserverutility.urlencode/cs/default.aspx.cs#1)]
[!code-vb[System.Web.HttpServerUtility.UrlEncode#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/system.web.httpserverutility.urlencode/vb/default.aspx.vb#1)]
The next example is similar to the previous example except it shows how to URL-encode a value from within a class that is not in the code-behind file.
[!code-csharp[System.Web.HttpServerUtility.UrlEncode#2](~/samples/snippets/csharp/VS_Snippets_WebNet/system.web.httpserverutility.urlencode/cs/sampleclass.cs#2)]
[!code-vb[System.Web.HttpServerUtility.UrlEncode#2](~/samples/snippets/visualbasic/VS_Snippets_WebNet/system.web.httpserverutility.urlencode/vb/sampleclass.vb#2)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="UrlEncode">
<MemberSignature Language="C#" Value="public void UrlEncode (string s, System.IO.TextWriter output);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void UrlEncode(string s, class System.IO.TextWriter output) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.UrlEncode(System.String,System.IO.TextWriter)" />
<MemberSignature Language="VB.NET" Value="Public Sub UrlEncode (s As String, output As TextWriter)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void UrlEncode(System::String ^ s, System::IO::TextWriter ^ output);" />
<MemberSignature Language="F#" Value="member this.UrlEncode : string * System.IO.TextWriter -&gt; unit" Usage="httpServerUtility.UrlEncode (s, output)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="s" Type="System.String" />
<Parameter Name="output" Type="System.IO.TextWriter" />
</Parameters>
<Docs>
<param name="s">The text string to encode.</param>
<param name="output">The <see cref="T:System.IO.TextWriter" /> output stream that contains the encoded string.</param>
<summary>URL-encodes a string and sends the resulting output to a <see cref="T:System.IO.TextWriter" /> output stream.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
URL encoding ensures that all browsers will correctly transmit text in URL strings. Characters such as a question mark (?), ampersand (&), slash mark (/), and spaces might be truncated or corrupted by some browsers. As a result, these characters must be encoded in `<a>` tags or in query strings where the strings can be re-sent by a browser in a request string.
<xref:System.Web.HttpServerUtility.UrlEncode%2A> is a convenient way to access the <xref:System.Web.HttpUtility.UrlEncode%2A?displayProperty=nameWithType> method at run time from an ASP.NET application. Internally, <xref:System.Web.HttpServerUtility.UrlEncode%2A> uses <xref:System.Web.HttpUtility.UrlEncode%2A?displayProperty=nameWithType> to encode strings.
To encode or decode values outside of a web application, use the <xref:System.Net.WebUtility> class.
## Examples
The following example encodes a string for transmission by HTTP. It encodes the string named `TestString`, which contains the text "This is a \<Test String>.", and copies it into the string named `EncodedString` as "This+is+a+%3cTest+String%3e.".
[!code-csharp[Classic HttpServerUtility.UrlEncode1 Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpServerUtility.UrlEncode1 Example/CS/source.cs#1)]
[!code-vb[Classic HttpServerUtility.UrlEncode1 Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpServerUtility.UrlEncode1 Example/VB/source.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="UrlPathEncode">
<MemberSignature Language="C#" Value="public string UrlPathEncode (string s);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance string UrlPathEncode(string s) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.UrlPathEncode(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function UrlPathEncode (s As String) As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::String ^ UrlPathEncode(System::String ^ s);" />
<MemberSignature Language="F#" Value="member this.UrlPathEncode : string -&gt; string" Usage="httpServerUtility.UrlPathEncode s" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="s" Type="System.String" />
</Parameters>
<Docs>
<param name="s">The text to URL-encode.</param>
<summary>Do not use; intended only for browser compatibility. Use <see cref="M:System.Web.HttpServerUtility.UrlEncode(System.String)" />.</summary>
<returns>The URL encoded text.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="UrlTokenDecode">
<MemberSignature Language="C#" Value="public static byte[] UrlTokenDecode (string input);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig unsigned int8[] UrlTokenDecode(string input) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.UrlTokenDecode(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function UrlTokenDecode (input As String) As Byte()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static cli::array &lt;System::Byte&gt; ^ UrlTokenDecode(System::String ^ input);" />
<MemberSignature Language="F#" Value="static member UrlTokenDecode : string -&gt; byte[]" Usage="System.Web.HttpServerUtility.UrlTokenDecode input" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Byte[]</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="input" Type="System.String" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
</Parameters>
<Docs>
<param name="input">The URL string token to decode.</param>
<summary>Decodes a URL string token to its equivalent byte array using base 64 digits.</summary>
<returns>The byte array containing the decoded URL string token.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.HttpServerUtility.UrlTokenDecode%2A> method converts a URL string token, which encodes binary data as base 64 digits, to its equivalent byte array representation. Use the <xref:System.Web.HttpServerUtility.UrlTokenDecode%2A> method to decode tokens transmitted on the URL and encoded by using the <xref:System.Web.HttpServerUtility.UrlTokenEncode%2A>.
The <xref:System.Web.HttpServerUtility.UrlTokenDecode%2A> method will return an empty byte array if the `input` parameter has a length of less than one.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The value of the <paramref name="input" /> parameter is <see langword="null" />.</exception>
<altmember cref="M:System.Convert.FromBase64CharArray(System.Char[],System.Int32,System.Int32)" />
<altmember cref="M:System.Web.HttpServerUtility.UrlTokenEncode(System.Byte[])" />
</Docs>
</Member>
<Member MemberName="UrlTokenEncode">
<MemberSignature Language="C#" Value="public static string UrlTokenEncode (byte[] input);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string UrlTokenEncode(unsigned int8[] input) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpServerUtility.UrlTokenEncode(System.Byte[])" />
<MemberSignature Language="VB.NET" Value="Public Shared Function UrlTokenEncode (input As Byte()) As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static System::String ^ UrlTokenEncode(cli::array &lt;System::Byte&gt; ^ input);" />
<MemberSignature Language="F#" Value="static member UrlTokenEncode : byte[] -&gt; string" Usage="System.Web.HttpServerUtility.UrlTokenEncode input" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="input" Type="System.Byte[]" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
</Parameters>
<Docs>
<param name="input">The byte array to encode.</param>
<summary>Encodes a byte array into its equivalent string representation using base 64 digits, which is usable for transmission on the URL.</summary>
<returns>The string containing the encoded token if the byte array *length* is greater than one; otherwise, an empty string ("").</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.HttpServerUtility.UrlTokenEncode%2A> method converts a byte array into an equivalent string representation encoded with base 64 digits. The resulting string token can be transmitted on the URL.
The <xref:System.Web.HttpServerUtility.UrlTokenEncode%2A> will return an empty string if the `input` parameter has a length of less than one.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The value of the <paramref name="input" /> parameter is <see langword="null" />.</exception>
<altmember cref="M:System.Convert.ToBase64String(System.Byte[])" />
<altmember cref="M:System.Web.HttpServerUtility.UrlTokenDecode(System.String)" />
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.