如何使用配置文件在ASP.NET? [英] How to use Profile in ASP.NET?

查看:146
本文介绍了如何使用配置文件在ASP.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试学习asp.net档案管理。但我在下面加XML名字,姓氏等。但我不能写个人资料。如果我尝试写配置文件属性。卓尔我的编辑简介:错误1名资料并不在当前的背景下存在C:\\ Documents和Settings \\ ykaratoprak \\桌面\\安全\\ WebApp_profile \\ WebApp_profile \\ Default.aspx.cs 18 13 WebApp_profile
我如何能做到?

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;
        }

推荐答案

要在你所描述的方式使用配置文件需要一个网站项目。你的问题意味着你有一个Web应用程序项目。

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

在Web应用程序项目中使用的配置文件是比至于是不是为您生成动态的ProfileCommon类网站更多的工作。

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.

<一个href=\"http://weblogs.asp.net/anasghanem/archive/2008/04/12/the-differences-in-profile-between-web-application-projects-wap-and-website.aspx\" rel=\"nofollow\">http://weblogs.asp.net/anasghanem/archive/2008/04/12/the-differences-in-profile-between-web-application-projects-wap-and-website.aspx

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

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

<一个href=\"http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx\" rel=\"nofollow\">http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx

这篇关于如何使用配置文件在ASP.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆