在VS2005 Web Site Projects项目中, 如果在Web.config文件中定义了Profile节,那么ASP.Net会自动为项目中的每个页面增加一个Profile的对象类型,这个对象类型完成了对定义在Web.config文件Profile节定义的所有属性进行强类型映射。开发员能够通过智能感知获得访问者的Profile信息,例如:

VS 2005 Web Application Project 项目中Profile的使用方法(更新)
在编写程序的时候,开发人员可以这样写:
VS 2005 Web Application Project 项目中Profile的使用方法(更新)
这种支持是使用VS2005 Web Site Project选项,动态建立和增加一个ProfileCommon类对象Profile到每一个Code-behind实例。
 
VS 2005 Web Application Project 项目中Profile的使用方法(更新)现在VS2005 Web Application Project 1.0英文版是不支持动态建立Profile对象,如果使用的项目是Web Applicaiton Project则不能发现Profile对象
VS 2005 Web Application Project 项目中Profile的使用方法(更新)解决的方法有两种
VS 2005 Web Application Project 项目中Profile的使用方法(更新)********************************************************************************
VS 2005 Web Application Project 项目中Profile的使用方法(更新) 一、自己Coding ProfileCommon类
VS 2005 Web Application Project 项目中Profile的使用方法(更新)    public class ProfileCommon : System.Web.Profile.ProfileBase
VS 2005 Web Application Project 项目中Profile的使用方法(更新)    {
VS 2005 Web Application Project 项目中Profile的使用方法(更新)        [SettingsAllowAnonymous(true)]
VS 2005 Web Application Project 项目中Profile的使用方法(更新)        public string TestString
VS 2005 Web Application Project 项目中Profile的使用方法(更新)        {
VS 2005 Web Application Project 项目中Profile的使用方法(更新)            get  { return base["TestString"] as string; }
VS 2005 Web Application Project 项目中Profile的使用方法(更新)            set  { base["TestString"] = value; }
VS 2005 Web Application Project 项目中Profile的使用方法(更新)        }
VS 2005 Web Application Project 项目中Profile的使用方法(更新)    }
VS 2005 Web Application Project 项目中Profile的使用方法(更新)在Web.config文件中要这样定义
VS 2005 Web Application Project 项目中Profile的使用方法(更新)
<profile defaultProvider="SqlServers" enabled="true" inherits="ProfileCommon" />
VS 2005 Web Application Project 项目中Profile的使用方法(更新)Code-Behind中
VS 2005 Web Application Project 项目中Profile的使用方法(更新)ProfileCommon profile = (ProfileCommon)HttpContext.Current.Profile;
VS 2005 Web Application Project 项目中Profile的使用方法(更新)profile.TestString ="Test";
VS 2005 Web Application Project 项目中Profile的使用方法(更新)********************************************************************************
VS 2005 Web Application Project 项目中Profile的使用方法(更新)********************************************************************************
VS 2005 Web Application Project 项目中Profile的使用方法(更新)二、使用第三方的Add-in  : ASP.Net WebProfile Generator 
VS 2005 Web Application Project 项目中Profile的使用方法(更新)什么是Asp.Net WebProfile Generator?
VS 2005 Web Application Project 项目中Profile的使用方法(更新)The Web Profile Generator is an add-in for Visual Studio 2005 that generates a strongly typed class for accessing the ASP.NET profile in Web Application
VS 2005 Web Application Project 项目中Profile的使用方法(更新)Projects. Because Web Application Projects compile the code behind files in advance of ASP.NET they do not have access to dynamically generated types like the Profile object.  
VS 2005 Web Application Project 项目中Profile的使用方法(更新)其实这个就是解决不能支持动态建立Profile对象的Add-in。
VS 2005 Web Application Project 项目中Profile的使用方法(更新)在使用时:
VS 2005 Web Application Project 项目中Profile的使用方法(更新)              1.安装 Asp.net WebProfile Generator Add-in.
VS 2005 Web Application Project 项目中Profile的使用方法(更新)              2.在工程中建议web.config并进行配置
<profile><properties>
VS 2005 Web Application Project 项目中Profile的使用方法(更新)              3.右击web.config文件有一个option:Generator WebProfile ,生成WebProfile.cs
VS 2005 Web Application Project 项目中Profile的使用方法(更新)              4. Profile.MyProperty就可以调用在web.Config中配置中配置项。 * MyProperty指配置项目的Name
VS 2005 Web Application Project 项目中Profile的使用方法(更新)*如果了解Profile的其他特性以下有两个的Link:
VS 2005 Web Application Project 项目中Profile的使用方法(更新)    http://quickstarts.asp.net/QuickStartv20/aspnet/doc/profile/default.aspx
VS 2005 Web Application Project 项目中Profile的使用方法(更新)    http://msdn2.microsoft.com/en-us/library/ms379605(VS.80).aspx
VS 2005 Web Application Project 项目中Profile的使用方法(更新)    http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=406eefba-2dd9-4d80-a48c-b4f135df4127 

 
VS 2005 Web Application Project 项目中Profile的使用方法(更新)ASP.Net WebProfile Generator 
VS 2005 Web Application Project 项目中Profile的使用方法(更新)Tim McBride has published a cool sample that will generate a WebProfile class for accessing the ASP.NET profile object from within the code behind files of a Web Application Project.
VS 2005 Web Application Project 项目中Profile的使用方法(更新)
VS 2005 Web Application Project 项目中Profile的使用方法(更新)http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=406eefba-2dd9-4d80-a48c-b4f135df4127
VS 2005 Web Application Project 项目中Profile的使用方法(更新)
VS 2005 Web Application Project 项目中Profile的使用方法(更新)Because Web Application Projects compile the code behind files in advance of ASP.NET they do not have access to dynamically generated types like the Profile object.  This sample provided an add-in into VS that will generate a WebProfile proxy class that will fetch profile information from the real ASP.NET profile object at runtime.
VS 2005 Web Application Project 项目中Profile的使用方法(更新)
VS 2005 Web Application Project 项目中Profile的使用方法(更新)Hope it helps,
VS 2005 Web Application Project 项目中Profile的使用方法(更新)Brad.
VS 2005 Web Application Project 项目中Profile的使用方法(更新)
VS 2005 Web Application Project 项目中Profile的使用方法(更新)

相关文章:VS 2005 Web Application Project 项目中Profile的使用方法[程序文档]

相关文章:

  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2021-06-28
  • 2021-08-05
  • 2022-12-23
  • 2021-11-02
猜你喜欢
  • 2021-12-07
  • 2021-08-05
  • 2022-02-07
  • 2021-04-09
相关资源
相似解决方案