Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
556 lines (507 sloc) 40.7 KB
<Type Name="HttpException" FullName="System.Web.HttpException">
<TypeSignature Language="C#" Value="public class HttpException : System.Runtime.InteropServices.ExternalException" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi serializable beforefieldinit HttpException extends System.Runtime.InteropServices.ExternalException" />
<TypeSignature Language="DocId" Value="T:System.Web.HttpException" />
<TypeSignature Language="VB.NET" Value="Public Class HttpException&#xA;Inherits ExternalException" />
<TypeSignature Language="C++ CLI" Value="public ref class HttpException : System::Runtime::InteropServices::ExternalException" />
<TypeSignature Language="F#" Value="type HttpException = class&#xA; inherit ExternalException" />
<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.Runtime.InteropServices.ExternalException</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute 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">
<AttributeName>System.Serializable</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Describes an exception that occurred during the processing of HTTP requests.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.HttpException> class is an HTTP-specific exception class that enables ASP.NET to generate exception information. For more information about throwing and handling exceptions, see [Exceptions](~/docs/standard/exceptions/index.md).
## Examples
The following code example demonstrates how to use the <xref:System.Web.HttpException> class to raise customized exceptions. The `Button_Click` method determines which button was clicked, and then calls either the `CheckNumber` or `CheckBoolean` method. If the user-entered value in the text box does not correspond to the expected type, an <xref:System.Web.HttpException> exception is created and thrown with a customized message based on the error type.
> [!IMPORTANT]
> This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07).
[!code-aspx-csharp[HttpException#1](~/samples/snippets/csharp/VS_Snippets_WebNet/HttpException/cs/httpexceptioncs.aspx#1)]
[!code-aspx-vb[HttpException#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/HttpException/vb/httpexceptionvb.aspx#1)]
]]></format>
</remarks>
<related type="Article" href="~/docs/standard/exceptions/index.md">Handling and Throwing Exceptions</related>
<related type="Article" href="https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07">Script Exploits Overview</related>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.HttpException" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public HttpException ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; HttpException();" />
<MemberType>Constructor</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>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.HttpException" /> class and creates an empty <see cref="T:System.Web.HttpException" /> object.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When handling exceptions, it can be useful to capture a series of related exceptions with the outer exception being thrown in response to an inner exception.
A reference to the inner exception that caused the outer exception is available from the <xref:System.Exception.InnerException%2A> property of the outer exception. This mechanism preserves the error information that is carried by earlier exceptions, including the original exceptions, while allowing you to create more meaningful outer exceptions. For more information, see <xref:System.Exception.InnerException%2A>.
## Examples
The following code example demonstrates the <xref:System.Web.HttpException.%23ctor%2A> constructor of the <xref:System.Web.HttpException> class. The `CheckNumber` method accepts a user-entered value through a text box and checks whether it is an integer. If the value is not an integer, an exception is thrown, and then a new <xref:System.Web.HttpException> object is created and thrown. That exception is caught in the `Button_Click` event handler and the error message is displayed on the browser.
> [!IMPORTANT]
> This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07).
[!code-aspx-csharp[HttpException_Constructor1#1](~/samples/snippets/csharp/VS_Snippets_WebNet/HttpException_Constructor1/CS/httpexception_constructor1.cs.aspx#1)]
[!code-aspx-vb[HttpException_Constructor1#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/HttpException_Constructor1/VB/httpexception_constructor1.vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="P:System.Exception.InnerException" />
<related type="Article" href="https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07">Script Exploits Overview</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public HttpException (string message);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string message) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.#ctor(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (message As String)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; HttpException(System::String ^ message);" />
<MemberSignature Language="F#" Value="new System.Web.HttpException : string -&gt; System.Web.HttpException" Usage="new System.Web.HttpException message" />
<MemberType>Constructor</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>
<Parameters>
<Parameter Name="message" Type="System.String" />
</Parameters>
<Docs>
<param name="message">The error message displayed to the client when the exception is thrown.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.HttpException" /> class using a supplied error message.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example demonstrates the <xref:System.Web.HttpException.%23ctor%2A> constructor of the <xref:System.Web.HttpException> class. An <xref:System.Web.HttpException> is thrown if a user-entered value is 0.
> [!IMPORTANT]
> This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07).
[!code-csharp[Classic HttpException.HttpException1 Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpException.HttpException1 Example/CS/source.cs#1)]
[!code-vb[Classic HttpException.HttpException1 Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpException.HttpException1 Example/VB/source.vb#1)]
]]></format>
</remarks>
<altmember cref="P:System.Exception.InnerException" />
<related type="Article" href="https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07">Script Exploits Overview</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public HttpException (int httpCode, string message);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(int32 httpCode, string message) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.#ctor(System.Int32,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (httpCode As Integer, message As String)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; HttpException(int httpCode, System::String ^ message);" />
<MemberSignature Language="F#" Value="new System.Web.HttpException : int * string -&gt; System.Web.HttpException" Usage="new System.Web.HttpException (httpCode, message)" />
<MemberType>Constructor</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>
<Parameters>
<Parameter Name="httpCode" Type="System.Int32" />
<Parameter Name="message" Type="System.String" />
</Parameters>
<Docs>
<param name="httpCode">The HTTP response status code sent to the client corresponding to this error.</param>
<param name="message">The error message displayed to the client when the exception is thrown.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.HttpException" /> class using an HTTP response status code and an error message.</summary>
<remarks>To be added.</remarks>
<altmember cref="P:System.Exception.InnerException" />
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="protected HttpException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig specialname rtspecialname instance void .ctor(class System.Runtime.Serialization.SerializationInfo info, valuetype System.Runtime.Serialization.StreamingContext context) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)" />
<MemberSignature Language="VB.NET" Value="Protected Sub New (info As SerializationInfo, context As StreamingContext)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; HttpException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);" />
<MemberSignature Language="F#" Value="new System.Web.HttpException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -&gt; System.Web.HttpException" Usage="new System.Web.HttpException (info, context)" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="info" Type="System.Runtime.Serialization.SerializationInfo" 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="context" Type="System.Runtime.Serialization.StreamingContext" 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="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
<param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that holds the contextual information about the source or destination.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.HttpException" /> class with serialized data.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.HttpException.%23ctor%2A> constructor is called during deserialization to reconstitute the exception object that is transmitted over a stream. For more information, see [XML and SOAP Serialization](~/docs/standard/serialization/xml-and-soap-serialization.md).
]]></format>
</remarks>
<altmember cref="T:System.Runtime.Serialization.SerializationInfo" />
<altmember cref="T:System.Runtime.Serialization.StreamingContext" />
<related type="Article" href="~/docs/standard/serialization/xml-and-soap-serialization.md">XML and SOAP Serialization</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public HttpException (string message, Exception innerException);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string message, class System.Exception innerException) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.#ctor(System.String,System.Exception)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (message As String, innerException As Exception)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; HttpException(System::String ^ message, Exception ^ innerException);" />
<MemberSignature Language="F#" Value="new System.Web.HttpException : string * Exception -&gt; System.Web.HttpException" Usage="new System.Web.HttpException (message, innerException)" />
<MemberType>Constructor</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>
<Parameters>
<Parameter Name="message" Type="System.String" />
<Parameter Name="innerException" Type="System.Exception" />
</Parameters>
<Docs>
<param name="message">The error message displayed to the client when the exception is thrown.</param>
<param name="innerException">The <see cref="P:System.Exception.InnerException" />, if any, that threw the current exception.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.HttpException" /> class using an error message and the <see cref="P:System.Exception.InnerException" /> property.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When handling exceptions, it can be useful to capture a series of related exceptions with the outer exception being thrown in response to an inner exception.
A reference to the inner exception that caused the outer exception is available from the <xref:System.Exception.InnerException%2A> property of the outer exception. This mechanism preserves the error information that is carried by earlier exceptions, including the original exceptions, while allowing you to create more meaningful outer exceptions. For more information, see <xref:System.Exception.InnerException%2A>.
## Examples
The following code example demonstrates the <xref:System.Web.HttpException.%23ctor%2A> constructor of the <xref:System.Web.HttpException> class. The `CheckNumber` method accepts a user-entered value through a text box and checks whether it is an integer. If the value is not an integer, an exception is thrown, and then in the catch block, a new <xref:System.Web.HttpException> object is created and thrown. That exception is caught in the `Button_Click` event handler and the error message is displayed on the browser.
> [!IMPORTANT]
> This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07).
[!code-aspx-csharp[HttpException_Constructor2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/HttpException_Constructor2/CS/httpexception_constructor2.cs.aspx#1)]
[!code-aspx-vb[HttpException_Constructor2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/HttpException_Constructor2/VB/httpexception_constructor2.vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="P:System.Exception.InnerException" />
<related type="Article" href="https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07">Script Exploits Overview</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public HttpException (string message, int hr);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string message, int32 hr) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.#ctor(System.String,System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (message As String, hr As Integer)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; HttpException(System::String ^ message, int hr);" />
<MemberSignature Language="F#" Value="new System.Web.HttpException : string * int -&gt; System.Web.HttpException" Usage="new System.Web.HttpException (message, hr)" />
<MemberType>Constructor</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>
<Parameters>
<Parameter Name="message" Type="System.String" />
<Parameter Name="hr" Type="System.Int32" />
</Parameters>
<Docs>
<param name="message">The error message displayed to the client when the exception is thrown.</param>
<param name="hr">The exception code that defines the error.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.HttpException" /> class using an error message and an exception code.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example demonstrates the <xref:System.Web.HttpException.%23ctor%2A> constructor of the <xref:System.Web.HttpException> class. An <xref:System.Web.HttpException> exception is thrown if a user-entered value is 0.
> [!IMPORTANT]
> This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07).
[!code-csharp[Classic HttpException.HttpException2 Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic HttpException.HttpException2 Example/CS/source.cs#1)]
[!code-vb[Classic HttpException.HttpException2 Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpException.HttpException2 Example/VB/source.vb#1)]
]]></format>
</remarks>
<altmember cref="P:System.Exception.InnerException" />
<related type="Article" href="https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07">Script Exploits Overview</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public HttpException (int httpCode, string message, Exception innerException);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(int32 httpCode, string message, class System.Exception innerException) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.#ctor(System.Int32,System.String,System.Exception)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (httpCode As Integer, message As String, innerException As Exception)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; HttpException(int httpCode, System::String ^ message, Exception ^ innerException);" />
<MemberSignature Language="F#" Value="new System.Web.HttpException : int * string * Exception -&gt; System.Web.HttpException" Usage="new System.Web.HttpException (httpCode, message, innerException)" />
<MemberType>Constructor</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>
<Parameters>
<Parameter Name="httpCode" Type="System.Int32" />
<Parameter Name="message" Type="System.String" />
<Parameter Name="innerException" Type="System.Exception" />
</Parameters>
<Docs>
<param name="httpCode">The HTTP response status code displayed on the client.</param>
<param name="message">The error message displayed to the client when the exception is thrown.</param>
<param name="innerException">The <see cref="P:System.Exception.InnerException" />, if any, that threw the current exception.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.HttpException" /> class using an HTTP response status code, an error message, and the <see cref="P:System.Exception.InnerException" /> property.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When handling exceptions, it can be useful to capture a series of related exceptions with the outer exception being thrown in response to an inner exception.
A reference to the inner exception that caused the outer exception is available from the <xref:System.Exception.InnerException%2A> property of the outer exception. This mechanism preserves the error information that is carried by earlier exceptions, including the original exceptions, while allowing you to create more meaningful outer exceptions. For more information, see <xref:System.Exception.InnerException%2A>.
## Examples
The following code example demonstrates the <xref:System.Web.HttpException.%23ctor%2A> constructor of the <xref:System.Web.HttpException> class. The `CheckNumber` method accepts a user-entered value and checks whether it is an integer. If the value is not an integer, an exception is thrown, and then a new <xref:System.Web.HttpException> object containing the HTTP response status code, the exception's message, and any inner exception is created. That exception is caught in the `Button_Click` event handler and the error message, error code, and inner exception are displayed.
> [!IMPORTANT]
> This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07).
[!code-aspx-csharp[HttpException_Constructor3#1](~/samples/snippets/csharp/VS_Snippets_WebNet/HttpException_Constructor3/CS/httpexception_constructor3.cs.aspx#1)]
[!code-aspx-vb[HttpException_Constructor3#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/HttpException_Constructor3/VB/httpexception_constructor3.vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="P:System.Exception.InnerException" />
<related type="Article" href="https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07">Script Exploits Overview</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public HttpException (int httpCode, string message, int hr);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(int32 httpCode, string message, int32 hr) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.#ctor(System.Int32,System.String,System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (httpCode As Integer, message As String, hr As Integer)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; HttpException(int httpCode, System::String ^ message, int hr);" />
<MemberSignature Language="F#" Value="new System.Web.HttpException : int * string * int -&gt; System.Web.HttpException" Usage="new System.Web.HttpException (httpCode, message, hr)" />
<MemberType>Constructor</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>
<Parameters>
<Parameter Name="httpCode" Type="System.Int32" />
<Parameter Name="message" Type="System.String" />
<Parameter Name="hr" Type="System.Int32" />
</Parameters>
<Docs>
<param name="httpCode">The HTTP response status code displayed on the client.</param>
<param name="message">The error message displayed to the client when the exception is thrown.</param>
<param name="hr">The exception code that defines the error.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.HttpException" /> class using an HTTP response status code, an error message, and an exception code.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example demonstrates the <xref:System.Web.HttpException.%23ctor%2A> constructor of the <xref:System.Web.HttpException> class. The user name and email information are entered by the user in the provided text boxes. If any of the text boxes are left blank, an <xref:System.Web.HttpException> object is created and thrown. The error code of the <xref:System.Web.HttpException> is obtained by the <xref:System.Web.HttpException.GetHttpCode%2A> method and displayed on the Web page.
> [!IMPORTANT]
> This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07).
[!code-aspx-csharp[HttpException_Constructor#1](~/samples/snippets/csharp/VS_Snippets_WebNet/HttpException_Constructor/CS/httpexception_constructor5.cs.aspx#1)]
[!code-aspx-vb[HttpException_Constructor#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/HttpException_Constructor/VB/httpexception_constructor5.vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="P:System.Exception.InnerException" />
<related type="Article" href="https://msdn.microsoft.com/library/772c7312-211a-4eb3-8d6e-eec0aa1dcc07">Script Exploits Overview</related>
</Docs>
</Member>
<Member MemberName="CreateFromLastError">
<MemberSignature Language="C#" Value="public static System.Web.HttpException CreateFromLastError (string message);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Web.HttpException CreateFromLastError(string message) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.CreateFromLastError(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function CreateFromLastError (message As String) As HttpException" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static System::Web::HttpException ^ CreateFromLastError(System::String ^ message);" />
<MemberSignature Language="F#" Value="static member CreateFromLastError : string -&gt; System.Web.HttpException" Usage="System.Web.HttpException.CreateFromLastError message" />
<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.Web.HttpException</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="message" Type="System.String" />
</Parameters>
<Docs>
<param name="message">The error message displayed to the client when the exception is thrown.</param>
<summary>Creates a new <see cref="T:System.Web.HttpException" /> exception based on the error code that is returned from the Windows API <see langword="GetLastError()" /> method.</summary>
<returns>An <see cref="T:System.Web.HttpException" /> based on the error code that is returned from a call to the Windows API <see langword="GetLastError()" /> method.</returns>
<remarks>To be added.</remarks>
<altmember cref="P:System.Exception.InnerException" />
</Docs>
</Member>
<Member MemberName="GetHtmlErrorMessage">
<MemberSignature Language="C#" Value="public string GetHtmlErrorMessage ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance string GetHtmlErrorMessage() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.GetHtmlErrorMessage" />
<MemberSignature Language="VB.NET" Value="Public Function GetHtmlErrorMessage () As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::String ^ GetHtmlErrorMessage();" />
<MemberSignature Language="F#" Value="member this.GetHtmlErrorMessage : unit -&gt; string" Usage="httpException.GetHtmlErrorMessage " />
<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 />
<Docs>
<summary>Gets the HTML error message to return to the client.</summary>
<returns>The HTML error message.</returns>
<remarks>To be added.</remarks>
<altmember cref="P:System.Exception.InnerException" />
</Docs>
</Member>
<Member MemberName="GetHttpCode">
<MemberSignature Language="C#" Value="public int GetHttpCode ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance int32 GetHttpCode() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.GetHttpCode" />
<MemberSignature Language="VB.NET" Value="Public Function GetHttpCode () As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; int GetHttpCode();" />
<MemberSignature Language="F#" Value="member this.GetHttpCode : unit -&gt; int" Usage="httpException.GetHttpCode " />
<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.Int32</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Gets the HTTP response status code to return to the client.</summary>
<returns>A non-zero HTTP code representing the exception or the <see cref="P:System.Exception.InnerException" /> code; otherwise, HTTP response status code 500.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If there is a non-zero HTTP code, it is returned. Otherwise, the <xref:System.Exception.InnerException%2A> code is returned. If neither an <xref:System.Exception.InnerException%2A> code nor a non-zero HTTP code is available, the HTTP response status code 500 is returned. For more information on HTTP response status codes, see the Status Code Definitions of the Hypertext Transfer Protocol - HTTP/1.1 on the World [Wide Web Consortium (W3C) Web site](https://go.microsoft.com/fwlink/?linkid=37125).
]]></format>
</remarks>
<altmember cref="P:System.Exception.InnerException" />
</Docs>
</Member>
<Member MemberName="GetObjectData">
<MemberSignature Language="C#" Value="public override void GetObjectData (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance void GetObjectData(class System.Runtime.Serialization.SerializationInfo info, valuetype System.Runtime.Serialization.StreamingContext context) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpException.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Sub GetObjectData (info As SerializationInfo, context As StreamingContext)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; override void GetObjectData(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);" />
<MemberSignature Language="F#" Value="override this.GetObjectData : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -&gt; unit" Usage="httpException.GetObjectData (info, context)" />
<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="info" Type="System.Runtime.Serialization.SerializationInfo" 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="context" Type="System.Runtime.Serialization.StreamingContext" 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="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
<param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that holds the contextual information about the source or destination.</param>
<summary>Gets information about the exception and adds it to the <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.HttpException.GetObjectData%2A> method adds information about the exception to the <xref:System.Runtime.Serialization.SerializationInfo> object that is targeted for serialization. During deserialization, the exception is reconstituted from the <xref:System.Runtime.Serialization.SerializationInfo> that is transmitted over the stream.
]]></format>
</remarks>
<altmember cref="T:System.Runtime.Serialization.SerializationInfo" />
<altmember cref="T:System.Runtime.Serialization.StreamingContext" />
<related type="Article" href="~/docs/standard/serialization/xml-and-soap-serialization.md">XML and SOAP Serialization</related>
</Docs>
</Member>
<Member MemberName="WebEventCode">
<MemberSignature Language="C#" Value="public int WebEventCode { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 WebEventCode" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpException.WebEventCode" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property WebEventCode As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property int WebEventCode { int get(); };" />
<MemberSignature Language="F#" Value="member this.WebEventCode : int" Usage="System.Web.HttpException.WebEventCode" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<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>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the event codes that are associated with the HTTP exception.</summary>
<value>An integer representing a Web event code.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.