如何在ASP.NET中使用Profile?

Pen*_*uen 6 .net c# asp.net profile

我尝试学习asp.net Profile Management.但我添加了xml firstName,LastName和其他.但我不能写简介.如果我尝试编写Profile属性.卓尔我的编辑器配置文件:错误1当前上下文中不存在名称"配置文件"C:\ Documents and Settings\ykaratoprak\Desktop\Security\WebApp_profile\WebApp_profile\Default.aspx.cs 18 13 WebApp_profile 我该怎么做?


    <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;
        }
Run Code Online (Sandbox Code Playgroud)

替代文字http://i47.tinypic.com/20juh2.gif

Sky*_*ers 6

以您描述的方式使用"个人档案"需要"网站"项目.您的问题意味着您有一个Web应用程序项目.

在Web应用程序项目中使用配置文件比使用Web站点更多,因为不会为您生成动态ProfileCommon类.

以下是一些帮助您了解差异的参考资料.

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

这是一个可以使Web应用程序中的配置文件更容易使用的工具.

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