HttpCapabilitiesBase.RequiresSpecialViewStateEncoding 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
브라우저에서 VIEWSTATE 값을 특별히 인코딩해야 하는지 여부를 나타내는 값을 가져옵니다.
public:
virtual property bool RequiresSpecialViewStateEncoding { bool get(); };
public virtual bool RequiresSpecialViewStateEncoding { get; }
member this.RequiresSpecialViewStateEncoding : bool
Public Overridable ReadOnly Property RequiresSpecialViewStateEncoding As Boolean
속성 값
브라우저에서 true 값을 특별히 인코딩해야 하면 VIEWSTATE이고, 그렇지 않으면 false입니다. 기본값은 false입니다.
예제
다음 코드 예제에서는 브라우저 VIEWSTATE 에 값을 특별히 인코딩해야 하는지 여부를 확인하는 방법을 보여 줍니다.
<%@ page language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(Object Sender, EventArgs e)
{
CheckBrowserCaps();
}
void CheckBrowserCaps()
{
String labelText = "";
System.Web.HttpBrowserCapabilities myBrowserCaps = Request.Browser;
if (((System.Web.Configuration.HttpCapabilitiesBase)myBrowserCaps).RequiresSpecialViewStateEncoding)
{
labelText = "Browser requires view state values to be specially encoded.";
}
else
{
labelText = "Browser does not require view state values to be specially encoded.";
}
Label1.Text = labelText;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Browser Capabilities Sample</title>
</head>
<body>
<form runat="server" id="form1">
<div>
Browser Capabilities:
<p/><asp:Label ID="Label1" Runat="server" />
</div>
</form>
</body>
</html>
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
CheckBrowserCaps()
End Sub
Function CheckBrowserCaps()
Dim labelText As String = ""
Dim myBrowserCaps As System.Web.HttpBrowserCapabilities = Request.Browser
If (CType(myBrowserCaps, System.Web.Configuration.HttpCapabilitiesBase)).RequiresSpecialViewStateEncoding Then
labelText = "Browser requires view state values to be specially encoded."
Else
labelText = "Browser does not require view state values to be specially encoded."
End If
Label1.Text = labelText
End Function 'CheckBrowserCaps
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Browser Capabilities Sample</title>
</head>
<body>
<form runat="server" id="form1">
<div>
Browser Capabilities:
<p/><asp:Label ID="Label1" Runat="server" />
</div>
</form>
</body>
</html>
설명
HTTP는 상태 비국적 프로토콜이며 VIEWSTATE 여러 요청에서 클라이언트 변경 내용을 유지하는 데 사용되는 하나의 메커니즘입니다. 웹 페이지의 각 컨트롤에는 클라이언트가 변경한 내용의 누적을 나타내는 속성이 포함되어 ViewState 있습니다. Web Forms 페이지에서 이러한 변경 내용은 특성이 있는 HTML <input> 요소의 포스트백 데이터로 hidden``value type 인코딩됩니다. 예를 들면 다음과 같습니다.
<input type="hidden" name="__VIEWSTATE" value="t0PH_u56?cDxleHQ7P=" />
이 경우 true값의 VIEWSTATE 알파벳이 아닌 문자가 브라우저 또는 중간 게이트웨이에서 올바르게 전송되지 않습니다. 이를 해결하기 위해 서버 제어 어댑터는 값의 VIEWSTATE 알파벳이 아닌 문자를 HTTP 요청에서 인코딩할 필요가 없는 문자로 바꿉니다.