Click here to Skip to main content
15,885,048 members
Articles / Web Development / ASP.NET

ASP.NET Profile Provider

Rate me:
Please Sign up or sign in to vote.
4.50/5 (14 votes)
25 Nov 2011CPOL4 min read 88.4K   4.3K   29  
Brief description of how to use the Profile Provider available in ASP.NET
<?xml version="1.0"?>
<configuration>
	<appSettings/>
	<connectionStrings>
		<add name="cnn" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;User Instance=True"/>
	</connectionStrings>
	<system.web>
		<authentication mode="Forms">
			<forms cookieless="UseCookies" defaultUrl="HomePage.aspx" loginUrl="UnAuthorized.aspx" protection="All" timeout="30"></forms>
		</authentication>
		<membership defaultProvider="Demo_MemberShipProvider">
   <providers>
    <add connectionStringName="cnn" enablePasswordRetrieval="false"
     enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/"
     requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5"
     minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0"
     passwordAttemptWindow="10" passwordStrengthRegularExpression=""
     name="Demo_MemberShipProvider" type="System.Web.Security.SqlMembershipProvider" />
   </providers>
  </membership>
		<roleManager enabled="true" cacheRolesInCookie="true" cookieName="DemoRoles">
   <providers>
    <add connectionStringName="cnn" applicationName="/" name="Demo_RoleProvider"
     type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   </providers>
  </roleManager>
		<authorization>
			<deny users="?"/>
			<allow users="*"/>
		</authorization>
    <anonymousIdentification  enabled="true"/>
		<profile defaultProvider="Demo_ProfileProvider">
			<providers>
				<add name="Demo_ProfileProvider" connectionStringName="cnn" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
			</providers>
			<properties>
				<add name="Name" type="String" allowAnonymous="true"/>
				<add name="DateofBirth" type="DateTime"  allowAnonymous="true"/>
				<add name="BirthPlace" type="string"  allowAnonymous="true"/>
        <add name="Place" type="string"  allowAnonymous="true"/>
				<add name="Languages" type="string"  allowAnonymous="true"/>
				<add name="AboutMe" type="String"  allowAnonymous="true"/>
				<add name="Employer" type="String"  allowAnonymous="true"/>
				<add name="Project" type="String"  allowAnonymous="true"/>
				<add name="Designation" type="String"  allowAnonymous="true"/>
				<add name="University" type="String"  allowAnonymous="true"/>
        <group name ="BasicInfo">
          <add name ="Name" type="String"/>
          <add name="DateofBirth" type="DateTime"/>
          <add name="BirthPlace" type="string"/>
          <add name="Place" type="string"/>
          <add name="Languages" type="string"/>
          <add name="AboutMe" type="String"/>
        </group>
        <group name ="ProfessionlProfile">
          <add name="Employer" type="String"/>
          <add name="Project" type="String"/>
          <add name="Designation" type="String"/>
          <add name="University" type="String"/>
        </group>
        <add name ="UserInfo" type ="UserInfo"/>
			</properties>
      
		</profile>
		<compilation debug="true" targetFramework="4.0"/>
		<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
	<location path="Login.aspx">
		<system.web>
			<authorization>
				<allow users="*"/>
			</authorization>
		</system.web>
	</location>
	<location path="DemoProfileProvider.aspx">
		<system.web>
			<authorization>
				<allow users="*"/>
			</authorization>
		</system.web>
	</location>
  <location path="Registration.aspx">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
</configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Collabera
Singapore Singapore
S V Sai Chandra is a Software Engineer from Hyderabad Deccan. He started Embedded Programing in his college days and now he is a Web Developer by Profession. He Loves coding and his passion has always been towards Microsoft Technologies. Apart from coding his other hobbies include reading books, painting and hang out with friends is his most favorite past time hobby.
He blogs at
http://technowallet.blogspot.com
Technical Skills:
C#,Ado.Net,Asp.Net,Sql Server,JavaScript,XML,Web services.

Comments and Discussions