Using a Profile in an ASP.NET Web Application

Possible duplicate:
How to assign profile values?

I am reading an ASP.NET book that says you cannot use a profile if you select a web application when starting a project. It works only under the website.

Are there any alternatives for web applications? Or you need to create your own profile system.

+5
source share
1 answer

You can use a profile provider if you use a web application instead of a website, but out of the box from the code for the aspx page, you cannot do it Profile.MyProperty.

, - . , - - , -.

" " , ProfileCommon

public class ProfileCommon
{
    public Teachers Teachers
    {
        get
        {
            return (Teachers)
                HttpContext.Current.Profile.GetPropertyValue("Teachers");
        }
        set
        {
            HttpContext.Current.Profile.SetPropertyValue("Teachers",value);
        }
    }
}

aspx

ProfileCommon Profile = new ProfileCommon();
protected void Button1_Click(object sender, EventArgs e)
{
    Teachers teachers = new Teachers();
    teachers.Add(new Teacher("scott"));
    teachers.Add(new Teacher("bob"));
    teachers.Add(new Teacher("paul"));

    Profile.Teachers = teachers;    
}

ProfileCommon Profile.Teachers

public static class Profile
{
    public static Teachers Teachers
    {
        //......
    }
}

, - ASP.NET.

,
, -. , TFS Build Manager -, -. , Microsoft -, -.

+8

All Articles