HttpParseException 클래스

정의

구문 분석 오류가 발생할 때 throw되는 예외입니다.

public ref class HttpParseException sealed : System::Web::HttpException
public sealed class HttpParseException : System.Web.HttpException
[System.Serializable]
public sealed class HttpParseException : System.Web.HttpException
type HttpParseException = class
    inherit HttpException
[<System.Serializable>]
type HttpParseException = class
    inherit HttpException
Public NotInheritable Class HttpParseException
Inherits HttpException
상속
특성

예제

다음 예제에서는 페이지 구문 분석 중에 생성된 오류를 사용자 지정하는 방법을 HttpParseException 보여 줍니다. 이 예제에서는 사용자 지정된 HtmlSelect 컨트롤이 정의됩니다. 사용자 지정 컨트롤의 자식 요소가 지정된 형식 HttpParseException 이 아닌 경우 사용자 지정GetChildControlType의 재정의된 HtmlSelectBuilder 메서드에서 throw됩니다. 구문 분석 예외를 생성하려면 자식 요소 리터럴 MyCustomOption 을 다른 문자열로 변경합니다.

<%@ Page Language="C#"%>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS" Assembly="Samples.AspNet.CS" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>HttpParseException Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
      <h3>HttpParseException Example</h3>

      <aspSample:CustomHtmlSelectWithHttpParseException
       id="customhtmlselect1"
       runat="server">
      <aspSample:MyCustomOption optionid="option1" value="1"/>
      <aspSample:MyCustomOption optionid="option2" value="2"/>
      <aspSample:MyCustomOption optionid="option3" value="3"/>
      </aspSample:CustomHtmlSelectWithHttpParseException>

    </form>

  </body>

</html>
<%@ Page Language="VB"%>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB" Assembly="Samples.AspNet.VB" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>HttpParseException Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
      <h3>HttpParseException Example</h3>

      <aspSample:CustomHtmlSelectWithHttpParseException
       id="customhtmlselect1"
       runat="server">
      <aspSample:MyCustomOption optionid="option1" value="1"/>
      <aspSample:MyCustomOption optionid="option2" value="2"/>
      <aspSample:MyCustomOption optionid="option3" value="3"/>
      </aspSample:CustomHtmlSelectWithHttpParseException>

    </form>

  </body>

</html>
using System;
using System.Security.Permissions;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Samples.AspNet.CS
{
    // Define a child control for the custom HtmlSelect.
    public class MyCustomOption
    {
        string _id;
        string _value;

        public string optionid
        {
            get
            { return _id; }
            set
            { _id = value; }
        }

        public string value
        {
            get
            { return _value; }
            set
            { _value = value; }
        }
    }

    // Define a custom HtmlSelectBuilder.
    public class MyHtmlSelectBuilderWithparseException : HtmlSelectBuilder
    {
        [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
        public override Type GetChildControlType(string tagName, IDictionary attribs)
        {
            // Distinguish between two possible types of child controls.
            if (tagName.ToLower().EndsWith("mycustomoption"))
            {
                return typeof(MyCustomOption);
            }
            else
            {
                throw new HttpParseException("This custom HtmlSelect control" +                                                  "requires child elements of the form \"MyCustomOption\"");
            }
        }
    }

    [ControlBuilderAttribute(typeof(MyHtmlSelectBuilderWithparseException))]
    public class CustomHtmlSelectWithHttpParseException : HtmlSelect
    {
        // Override the AddParsedSubObject method.
        protected override void AddParsedSubObject(object obj)
        {

            string _outputtext;
            if (obj is MyCustomOption)
            {
                _outputtext = "custom select option : " + ((MyCustomOption)obj).value;
                ListItem li = new ListItem(_outputtext, ((MyCustomOption)obj).value);
                base.Items.Add(li);
            }
        }
    }
}
Imports System.Security.Permissions
Imports System.Collections
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Namespace Samples.AspNet.VB
    ' Define a child control for the custom HtmlSelect.
    Public Class MyCustomOption
        Private _id As String
        Private _value As String


        Public Property optionid() As String
            Get
                Return _id
            End Get
            Set(ByVal value As String)
                _id = value
            End Set
        End Property

        Public Property value() As String
            Get
                Return _value
            End Get
            Set(ByVal value As String)
                _value = value
            End Set
        End Property
    End Class

    ' Define a custom HtmlSelectBuilder.
    Public Class MyHtmlSelectBuilderWithparseException
        Inherits HtmlSelectBuilder

        <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
        Public Overrides Function GetChildControlType(ByVal tagName As String, ByVal attribs As IDictionary) As Type

            ' Distinguish between two possible types of child controls.
            If tagName.ToLower().EndsWith("mycustomoption") Then

                Return GetType(MyCustomOption)

            Else
                
                Throw New HttpParseException("This custom HtmlSelect control" & _ 
                         "requires child elements of the form ""MyCustomOption""")
            End If

        End Function

    End Class


    <ControlBuilderAttribute(GetType(MyHtmlSelectBuilderWithparseException))> _
    Public Class CustomHtmlSelectWithHttpParseException
        Inherits HtmlSelect

        ' Override the AddParsedSubObject method.
        Protected Overrides Sub AddParsedSubObject(ByVal obj As Object)

            Dim _outputtext As String
            If TypeOf obj Is MyCustomOption Then
                _outputtext = "custom select option : " + CType(obj, MyCustomOption).value
                Dim li As New ListItem(_outputtext, CType(obj, MyCustomOption).value)
                MyBase.Items.Add(li)
            End If

        End Sub

    End Class

End Namespace

설명

HttpParseException 클래스는 ASP.NET 파서 예외 정보를 출력할 수 있도록 하는 HTTP 관련 예외 클래스입니다. 예외를 throw하고 처리하는 방법에 대한 자세한 내용은 예외를 참조 하세요.

생성자

Name Description
HttpParseException()

HttpParseException 클래스의 새 인스턴스를 초기화합니다.

HttpParseException(String, Exception, String, String, Int32)

컴파일되는 소스 코드 및 예외가 발생한 줄 번호에 대한 특정 정보를 사용하여 클래스의 새 인스턴스 HttpParseException 를 초기화합니다.

HttpParseException(String, Exception)

지정된 오류 메시지와 내부 참조를 사용하여 클래스의 HttpParseException 새 인스턴스를 초기화합니다.

HttpParseException(String)

지정된 오류 메시지를 사용하여 클래스의 HttpParseException 새 인스턴스를 초기화합니다.

속성

Name Description
Data

예외에 대한 추가 사용자 정의 정보를 제공하는 키/값 쌍의 컬렉션을 가져옵니다.

(다음에서 상속됨 Exception)
ErrorCode

오류의 HRESULT 값을 가져옵니다.

(다음에서 상속됨 ExternalException)
FileName

오류가 발생할 때 구문 분석할 파일의 이름을 가져옵니다.

HelpLink

이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
HResult

특정 예외에 할당된 코딩된 숫자 값인 HRESULT를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
InnerException

현재 예외를 Exception 발생시킨 인스턴스를 가져옵니다.

(다음에서 상속됨 Exception)
Line

오류가 발생할 때 구문 분석할 줄의 수를 가져옵니다.

Message

현재 예외를 설명하는 메시지를 가져옵니다.

(다음에서 상속됨 Exception)
ParserErrors

현재 예외에 대한 파서 오류를 가져옵니다.

Source

오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
StackTrace

호출 스택에서 직접 실행 프레임의 문자열 표현을 가져옵니다.

(다음에서 상속됨 Exception)
TargetSite

현재 예외를 throw하는 메서드를 가져옵니다.

(다음에서 상속됨 Exception)
VirtualPath

오류를 생성한 원본 파일의 가상 경로를 가져옵니다.

WebEventCode

HTTP 예외와 연결된 이벤트 코드를 가져옵니다.

(다음에서 상속됨 HttpException)

메서드

Name Description
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetBaseException()

파생 클래스에서 재정의되는 경우 하나 이상의 후속 예외의 근본 원인인 값을 반환 Exception 합니다.

(다음에서 상속됨 Exception)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetHtmlErrorMessage()

클라이언트로 반환할 HTML 오류 메시지를 가져옵니다.

(다음에서 상속됨 HttpException)
GetHttpCode()

클라이언트로 반환할 HTTP 응답 상태 코드를 가져옵니다.

(다음에서 상속됨 HttpException)
GetObjectData(SerializationInfo, StreamingContext)

파생 클래스에서 재정의되는 경우 예외에 SerializationInfo 대한 정보를 사용하여 개체를 설정합니다.

GetType()

현재 인스턴스의 런타임 형식을 가져옵니다.

(다음에서 상속됨 Exception)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

오류의 HRESULT를 포함하는 문자열을 반환합니다.

(다음에서 상속됨 ExternalException)

이벤트

Name Description
SerializeObjectState
사용되지 않음.

예외에 대한 직렬화된 데이터를 포함하는 예외 상태 개체를 만들기 위해 예외가 serialize될 때 발생합니다.

(다음에서 상속됨 Exception)

적용 대상

추가 정보