ProfileBase 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ProfileBase 클래스의 인스턴스를 만듭니다.
public:
ProfileBase();
public ProfileBase();
Public Sub New ()
예외
enabledWeb.config 파일의 프로필 섹션 특성입니다false.
Web.config 파일의 프로필 섹션에 지정된 속성 형식을 만들 수 없습니다.
-또는-
-또는-
serializeAsWeb.config 파일의 프로필 섹션에 있는 속성의 특성이 설정 Binary 되고 IsSerializable 지정된 type 속성의 속성이 반환됩니다false.
-또는-
프로필 속성의 특성을 사용하여 provider 지정된 공급자의 이름을 컬렉션에서 Providers 찾을 수 없습니다.
-또는-
type 프로필 속성에 대해 지정된 것을 찾을 수 없습니다.
-또는-
프로필 속성은 프로필 섹션의 특성에 지정된 기본 클래스의 속성 이름과 일치하는 이름으로 지정되었습니다inherits.
예제
다음 Web.config 파일은 형식의 속성과 RecentSearchList 형식 string 의 속성을 StringCollection포함하는 ZipCode 사용자 프로필을 지정합니다. 현재 HttpContext 생성된 Profile 속성에는 지정된 각 속성에 대해 강력한 형식의 접근자가 있습니다.
<configuration>
<connectionStrings>
<add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />
</connectionStrings>
<system.web>
<anonymousIdentification enabled="true" />
<profile defaultProvider="SqlProvider" >
<providers>
<add
name="SqlProvider"
connectionStringName="SqlServices"
applicationName="ProfileBaseApplication"
type="System.Web.Profile.SqlProfileProvider" />
</providers>
<properties>
<add name="ZipCode" allowAnonymous="true" />
<add name="RecentSearchList"
type="System.Collections.Specialized.StringCollection"
serializeAs="Xml"
allowAnonymous="true" />
</properties>
</profile>
</system.web>
</configuration>
다음 ASP.NET 페이지에서는 사용자 프로필에 ZipCode 지정된 속성을 읽고 설정합니다.
중요합니다
이 예제에는 잠재적인 보안 위협인 사용자 입력을 허용하는 텍스트 상자가 포함되어 있습니다. 기본적으로 ASP.NET 웹 페이지는 사용자 입력에 스크립트 또는 HTML 요소가 포함되지 않는지 확인합니다. 자세한 내용은 스크립트 악용 개요를 참조하세요.
<%@ 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">
public void Page_PreRender()
{
if (Profile.ZipCode == null)
{
PersonalizePanel.Visible = false;
GetZipCodePanel.Visible = true;
}
else
{
ZipCodeLabel.Text = Profile.ZipCode;
// Get personalized information for zip code here.
PersonalizePanel.Visible = true;
GetZipCodePanel.Visible = false;
}
}
public void ChangeZipCode_OnClick(object sender, EventArgs args)
{
ZipCodeTextBox.Text = Profile.ZipCode;
Profile.ZipCode = null;
PersonalizePanel.Visible = false;
GetZipCodePanel.Visible = true;
}
public void EnterZipCode_OnClick(object sender, EventArgs args)
{
Profile.ZipCode = ZipCodeTextBox.Text;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Home Page</title>
</head>
<body>
<form id="form1" runat="server">
<table border="1" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Panel id="PersonalizePanel" runat="Server" Visible="False">
Information for Zip Code: <asp:Label id="ZipCodeLabel" Runat="Server" /><br />
<!-- Information for Zip Code here. -->
<br />
<asp:LinkButton id="ChangeZipCodeButton" Runat="Server" Text="Change Your Zip Code"
OnClick="ChangeZipCode_OnClick" />
</asp:Panel>
<asp:Panel id="GetZipCodePanel" runat="Server" Visible="False">
You can personalize this page by entering your Zip Code:
<asp:TextBox id="ZipCodeTextBox" Columns="5" MaxLength="5" runat="Server" />
<asp:LinkButton id="EnterZipCodeButton" Runat="Server" Text="Go"
OnClick="EnterZipCode_OnClick" />
</asp:Panel>
</td>
</tr>
</table>
</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">
Public Sub Page_PreRender()
If Profile.ZipCode = Nothing Then
PersonalizePanel.Visible = False
GetZipCodePanel.Visible = True
Else
ZipCodeLabel.Text = Profile.ZipCode
' Get personalized information for zip code here.
PersonalizePanel.Visible = True
GetZipCodePanel.Visible = False
End If
End Sub
Public Sub ChangeZipCode_OnClick(sender As Object, args As EventArgs)
ZipCodeTextBox.Text = Profile.ZipCode
Profile.ZipCode = Nothing
PersonalizePanel.Visible = False
GetZipCodePanel.Visible = True
End Sub
Public Sub EnterZipCode_OnClick(sender As Object, args As EventArgs)
Profile.ZipCode = ZipCodeTextBox.Text
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Home Page</title>
</head>
<body>
<form id="form1" runat="server">
<table border="1" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Panel id="PersonalizePanel" runat="Server" Visible="False">
Information for Zip Code: <asp:Label id="ZipCodeLabel" Runat="Server" /><br />
<!-- Information for Zip Code here. -->
<br />
<asp:LinkButton id="ChangeZipCodeButton" Runat="Server" Text="Change Your Zip Code"
OnClick="ChangeZipCode_OnClick" />
</asp:Panel>
<asp:Panel id="GetZipCodePanel" runat="Server" Visible="False">
You can personalize this page by entering your Zip Code:
<asp:TextBox id="ZipCodeTextBox" Columns="5" MaxLength="5" runat="Server" />
<asp:LinkButton id="EnterZipCodeButton" Runat="Server" Text="Go"
OnClick="EnterZipCode_OnClick" />
</asp:Panel>
</td>
</tr>
</table>
</form>
</body>
</html>
설명
ASP.NET 클래스를 ProfileBase 사용하여 사용자 프로필에 사용되는 클래스를 만듭니다. 사용자 프로필을 사용하도록 설정된 애플리케이션이 시작되면 ASP.NET 클래스에서 상속되는 새 형식 ProfileCommon클래스를 ProfileBase 만듭니다. 강력한 형식의 접근자는 프로필 구성 섹션에 ProfileCommon 정의된 각 속성에 대한 클래스에 추가됩니다. 클래스의 강력한 형식의 ProfileCommon 접근자가 각각 기본 클래스의 ProfileBase 메서드 및 SetPropertyValue 메서드를 호출 GetPropertyValue 하여 프로필 속성 값을 검색하고 설정합니다. 클래스의 ProfileCommon 인스턴스는 ASP.NET 애플리케이션의 Profile 속성 값으로 설정됩니다.
메모
속성에 저장된 Profile 클래스를 생성하는 데 사용되는 기본 클래스는 구성 파일의 프로필 섹션 특성을 사용하여 inherits 재정의할 수 있습니다. 이 경우 기본 클래스에서 상속되는 사용자 지정 클래스를 ProfileBase 지정합니다.
이 생성자는 애플리케이션 코드에서 사용할 수 없습니다. 사용자 프로필의 인스턴스를 만들려면 메서드를 Create 사용합니다.