This documentation is archived and is not being maintained.

HttpException Constructor (String, Int32)

Initializes a new instance of the HttpException class using an error message and an exception code.

Namespace: System.Web
Assembly: System.Web (in system.web.dll)

public HttpException (
	string message,
	int hr
)
public HttpException (
	String message, 
	int hr
)
public function HttpException (
	message : String, 
	hr : int
)

Parameters

message

The error message displayed to the client when the exception is thrown.

hr

The exception code that defines the error.

The following code example demonstrates the HttpException constructor of the HttpException class. An HttpException exception is thrown if a user-entered value is 0.

if (Num == 0)
{
   throw new HttpException("No value entered", 100);
}
   

if (num == 0) {
    throw new HttpException("No value entered", 100);
}        

if(num == 0){
   throw new HttpException("No value entered", 100)
}
   

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: