次の方法で共有


HttpException コンストラクタ (String, Int32)

エラー メッセージと例外コードを使用して、HttpException クラスの新しいインスタンスを初期化します。

名前空間: System.Web
アセンブリ: System.Web (system.web.dll 内)

構文

'宣言
Public Sub New ( _
    message As String, _
    hr As Integer _
)
'使用
Dim message As String
Dim hr As Integer

Dim instance As New HttpException(message, hr)
public HttpException (
    string message,
    int hr
)
public:
HttpException (
    String^ message, 
    int hr
)
public HttpException (
    String message, 
    int hr
)
public function HttpException (
    message : String, 
    hr : int
)
適用できません。

パラメータ

  • message
    例外がスローされたときに、クライアントに表示するエラー メッセージ。
  • hr
    エラーを定義する例外コード。

使用例

HttpException クラスの HttpException コンストラクタのコード例を次に示します。ユーザー入力値が 0 の場合は HttpException 例外がスローされます。

セキュリティに関するメモセキュリティに関するメモ :

この例には、ユーザー入力を受け付けるテキスト ボックスがあります。これにより、セキュリティが脆弱になる可能性があります。既定では、ASP.NET Web ページによって、ユーザー入力にスクリプトまたは HTML 要素が含まれていないかどうかが検証されます。詳細については、「スクリプトによる攻略の概要」を参照してください。

If Num = 0 Then
   Throw New HttpException("No value entered", 100)
end if
   
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 Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

HttpException クラス
HttpException メンバ
System.Web 名前空間
InnerException

その他の技術情報

スクリプトによる攻略の概要