我尝试学习asp.net Profile Management。但我添加了xml firstName,LastName和其他。但我不能写简介。如果我尝试编写Profile属性。卓尔我的编辑器简介:错误1当前上下文中不存在名称'Profile'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;
}
答案 0 :(得分:5)
以您描述的方式使用“个人档案”需要“网站”项目。您的问题意味着您有一个Web应用程序项目。
在Web应用程序项目中使用配置文件比使用Web站点更多的工作,因为不会为您生成动态的ProfileCommon类。
以下是一些帮助您了解差异的参考资料。
这是一个可以使Web应用程序中的配置文件更容易使用的工具。
答案 1 :(得分:1)
此URL描述了如何解决Web应用程序中的“个人档案”问题:Using ASP.Net Profile Feature in a Web Application Project
答案 2 :(得分:0)
在页面 System.Web.Profile
中添加此命名空间using System.Web.Profile;
答案 3 :(得分:0)
问题是Profile
已存在于web.config中。因此,您必须将您的属性添加到配置文件中,擦除使用System.Web.Profile并再次编写它(使用System.Web.Profile;)。