Windows Azure ASP.NET Providers Sample

The Windows Azure ASP.NET Providers sample shows how to use tables and blobs in Windows Azure storage to host Membership records, Profile records, Role records and Session State information with custom ASP.NET Providers.

C# (7.1 MB)
 
 
 
 
 
4.1 Star
(10)
7,036 times
Add to favorites
7/29/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
// -----------------------------------------------------------------------
// <copyright file="UserProfile.cs" company="Microsoft">
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Microsoft Public License.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
// </copyright>
// -----------------------------------------------------------------------

namespace AspProvidersDemoWebRole
{
    using System.Web.Profile;
    using System.Web.Security;

    /// <summary>
    /// Class to store application-specific user Profile information.
    /// </summary>
    public class UserProfile : ProfileBase
    {
        [SettingsAllowAnonymous(false)]
        public string Country
        {
            get { return base["Country"] as string; }
            set { base["Country"] = value; }
        }

        [SettingsAllowAnonymous(false)]
        public string Gender
        {
            get { return base["Gender"] as string; }
            set { base["Gender"] = value; }
        }

        [SettingsAllowAnonymous(false)]
        public int Age
        {
            get { return (int)base["Age"]; }
            set { base["Age"] = value; }
        }

        public static UserProfile GetUserProfile(string userName)
        {
            return Create(userName) as UserProfile;
        }

        public static UserProfile GetUserProfile()
        {
            return Create(Membership.GetUser().UserName) as UserProfile;
        }
    }
}