ProfileBase 생성자

정의

ProfileBase 클래스의 인스턴스를 만듭니다.

public:
 ProfileBase();
public ProfileBase ();
Public Sub New ()

예외

Web.config 파일에 있는 profile 섹션의 enabled 특성이 false인 경우

Web.config 파일의 profile 섹션에 지정된 속성 형식을 만들 수 없는 경우

또는

Web.config 파일의 profile 섹션에서 속성의 allowAnonymous 특성이 true로 설정되어 있고 <anonymousIdentification> 요소의 enabled 특성이 false로 설정되어 있는 경우

또는

Web.config 파일의 profile 섹션에서 속성의 serializeAs 특성이 Binary로 설정되어 있고 지정된 typeIsSerializable 속성이 false를 반환하는 경우

또는

프로필 속성의 provider 특성을 사용하여 지정한 공급자 이름을 Providers 컬렉션에서 찾을 수 없는 경우

또는

프로필 속성에 지정된 type을 찾을 수 없는 경우

또는

프로필 속성이 profile 섹션의 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 요소가 포함되어 있지 않은지 확인합니다. 자세한 내용은 Script Exploits Overview를 참조하세요.

<%@ 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 접근자 클래스는 각각 프로필 속성 값을 검색하고 설정하기 위해 기본 클래스의 ProfileBaseSetPropertyValue 메서드를 호출 GetPropertyValue 합니다. 인스턴스를 ProfileCommon 클래스의 값으로 설정 됩니다는 Profile ASP.NET 애플리케이션에 대 한 속성입니다.

참고

속성에 저장된 Profile 클래스를 생성하는 데 사용되는 기본 클래스는 구성 파일의 프로필 섹션 특성을 사용하여 inherits 재정의할 수 있습니다. 이 경우 기본 클래스에서 상속되는 사용자 지정 클래스를 ProfileBase 지정합니다.

이 생성자는 애플리케이션 코드에서 사용할 수 없습니다. 사용자 프로필의 인스턴스를 만들려면 메서드를 Create 사용합니다.

적용 대상

추가 정보