zoukankan      html  css  js  c++  java
  • VS 2005 Web Application Project 项目中Profile的使用方法(更新)

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

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

     
    ASP.Net WebProfile Generator 
    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.

    http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=406eefba-2dd9-4d80-a48c-b4f135df4127

    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.

    Hope it helps,
    Brad.


    相关文章:VS 2005 Web Application Project 项目中Profile的使用方法[程序文档]
  • 相关阅读:
    github not authorized eclipse 关于 代码不能提交到GitHub
    idea 导入项目后 有的项目目录结构不展开解决办法
    intellij idea 主题大全,看不惯idea 那2种主题的来这里了
    win10 系统输入法与 idea的 ctr+shift+f 快捷键冲突,解决办法
    此地址使用了一个通常用于网络浏览以外目的的端口。出于安全原因,Firefox 取消了该请求。
    关于IntelliJ IDEA有时候快捷键无效的说明
    杜恩德是谁?
    oracle如何连接别人的数据库,需要在本地添加一些配置
    2.6---找有环链表的开头结点(CC150)
    2.3---删除链表的结点,不提供头结点(CC150)
  • 原文地址:https://www.cnblogs.com/RuiLei/p/639525.html
Copyright © 2011-2022 走看看