从 ProfileBase 类继承

    创建自定义配置文件,可以在应用程序的 Web.config 文件中的 profile 配置元素的 inherits 属性中指定。
    Web.config总的设置:
    <profile inherits="EmployeeProfile">   
    </profile>。

using  System;
using  System.Web.Profile;

namespace  Samples.AspNet.Profile
{
  
public class EmployeeProfile : ProfileBase
  
{
    [SettingsAllowAnonymous(
false)]
    [ProfileProvider(
"EmployeeInfoProvider")]
    
public string Department
    
{
      
get return base["EmployeeDepartment"].ToString(); }
      
set base["EmployeeDepartment"= value; }
    }


    [SettingsAllowAnonymous(
false)]
    [ProfileProvider(
"EmployeeInfoProvider")]
    
public EmployeeInfo Details
    
{
      
get return (EmployeeInfo)base["EmployeeInfo"]; }
      
set base["EmployeeInfo"= value; }
    }


  }


  
public class EmployeeInfo
  
{
    
public string Name;
    
public string Address;
    
public string Phone;
    
public string EmergencyContactName;
    
public string EmergencyContactAddress;
    
public string EmergencyContactPhone;
  }

}

你可能感兴趣的:(从 ProfileBase 类继承)