Penguen
Penguen

Reputation: 17278

How to use Profile in ASP.NET?

i try to learn asp.net Profile management. But i added below xml firstName,LastName and others. But i cannot write Profile. if i try to write Profile property. drow my editor Profile : Error 1 The name 'Profile' does not exist in the current context C:\Documents and Settings\ykaratoprak\Desktop\Security\WebApp_profile\WebApp_profile\Default.aspx.cs 18 13 WebApp_profile How can i do that?


    <authentication mode="Windows"/>
    <profile>
      <properties>
        <add name="FirstName"/>
        <add name="LastName"/>
        <add name="Age"/>
        <add name="City"/>
      </properties>
    </profile>


 protected void Button1_Click(object sender, System.EventArgs e)
        {
            Profile.FirstName = TextBox1.Text;
            Profile.LastName = TextBox2.Text;
            Profile.Age = TextBox3.Text;
            Profile.City = TextBox4.Text;

            Label1.Text = "Profile stored successfully!<br />" +
                "<br />First Name: " + Profile.FirstName +
                "<br />Last Name: " + Profile.LastName +
                "<br />Age: " + Profile.Age +
                "<br />City: " + Profile.City;
        }

alt text

Upvotes: 6

Views: 9989

Answers (4)

Sky Sanders
Sky Sanders

Reputation: 37074

To use Profiles in the manner you describe requires a Web Site project. Your question implies that you have a Web Application project.

Using profiles in a Web Application project is a little more work than with a Web Site as the dynamic ProfileCommon class is not generated for you.

Here are some references to help you understand the differences.

http://weblogs.asp.net/anasghanem/archive/2008/04/12/the-differences-in-profile-between-web-application-projects-wap-and-website.aspx

And here is a tool that can make using profiles in Web Applications easier.

http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx

Upvotes: 7

Juan Felipe
Juan Felipe

Reputation: 1

The problem is that Profile Already exists in web.config. So you have to add your properties into the profile, erase the using System.Web.Profile and write it again (Using System.Web.Profile;).

Upvotes: 0

GMG
GMG

Reputation: 31

This URL describes how to work around the issue with Profiles within a Web Application: Using ASP.Net Profile Feature in a Web Application Project

Upvotes: 1

this. __curious_geek
this. __curious_geek

Reputation: 43207

Add this namespace in your page System.Web.Profile

using System.Web.Profile;

Upvotes: 0

Related Questions