首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

网站项目中Profile的引用有关问题

2012-08-27 
网站项目中Profile的引用问题web.config文件HTML code?xml version1.0?!--有关如何配置 ASP.NET 应

网站项目中Profile的引用问题
web.config文件

HTML code
<?xml version="1.0"?><!--  有关如何配置 ASP.NET 应用程序的详细信息,请访问  http://go.microsoft.com/fwlink/?LinkId=169433  --><configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">    <system.web>            <authorization>        <deny users="?" />      </authorization>      <authentication mode="Forms" />      <compilation debug="true" targetFramework="4.0"/>      <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">        <providers>          <clear />          <add          name="SqlProvider"          type="System.Web.Security.SqlMembershipProvider"          connectionStringName="NorthwindConnectionString"          applicationName="northWind"          enablePasswordRetrieval="false"          enablePasswordReset="true"          requiresQuestionAndAnswer="true"          requiresUniqueEmail="true"          passwordFormat="Hashed" />        </providers>      </membership>            <roleManager defaultProvider="SqlProvider"        enabled="true"        cacheRolesInCookie="true"        cookieName=".ASPROLES"        cookieTimeout="30"        cookiePath="/"        cookieRequireSSL="false"        cookieSlidingExpiration="true"        cookieProtection="All" >        <providers>          <add          name="SqlProvider"          type="System.Web.Security.SqlRoleProvider"          connectionStringName="NorthwindConnectionString"          applicationName="northWind" />        </providers>      </roleManager>    </system.web>  <connectionStrings>    <add name="NorthwindConnectionString" connectionString="Data Source=XXX-PC;Initial Catalog=aspnetdb;Integrated Security=True;"      providerName="System.Data.Sqlclient" />    [color=#FF0000]<profile>      <properties>        <add name="Country"/>        <add name="Visits" type="System.Int32" defaultValue="0"/>        <add name="LastVisit" type="System.DateTime"/>      </properties>    </profile>[/color]    <add name="EventsConnectionString" connectionString="Data Source=XXX-PC;Initial Catalog=BegVCSharpEvents;Integrated Security=True"      providerName="System.Data.SqlClient" />  </connectionStrings>   </configuration>

红色部分为Profile的代码配置


ProfileDemo.aspx文件
C# code
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class ProfileDemo : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        if (!Page.IsPostBack)        {            DropDownListCountries.SelectedValue = Profile.Country;        }        LabelLastVisit.Text = Profile.LastVisit.ToLongTimeString();        LabelVisitCount.Text = Profile.Visits.ToString();        LabelSelectedCountry.Text = Profile.Country;        Profile.Visits++;        Profile.LastVisit = DateTime.Now;        Profile.Save();    }    protected void onCountrySelection(object sender, EventArgs e)    {          Profile.Country = this.DropDownListCountries.SelectedItem.Value;          Profile.Save();     }}

在ProfileDemo.aspx文件中,不能对Profile的属性进行引用,
出现“所引用内容是否缺少using 引用或程序集指令”错误,还有个我不是很清楚关于配置文件中Profile代码段的所放的具体位置如何。


在线等大牛指教。
【注】这个是网站项目而不是要自己定义Profile类的web应用程序。

[解决办法]
http://miniprofiler.com/

一个微软开源项目

Profile 需要配置数据库,一般项目用的少
[解决办法]
当你定义好一个profile之后,系统会自动在下一次页面被调用时,生成一个与该profile相对应的类。这个类会被保存在"Temporary ASP.NET Files Directory"目录(该目录也用于存放用于动态生成页面的类)。你可以使用HttpContext的Profile属性(Property)调用该类。
当你定义好一个profile后,你可以使用如下方法为profile属性赋值。

来自
http://www.cnblogs.com/shanyou/archive/2007/06/29/800755.html

好像应该没有问题啊,重新编译一下试一试。
你读一下那篇文章,看看是不是哪里漏掉了。
[解决办法]
你自己对照一下之前的rolemanager、membership节。你的profile节东西太少了,光定义了property,provider呢?
[解决办法]
终极答案:

傻逼才会使用application \session\profile\membership....等等一切微软封装的

Web开发,只需要使用html/js等,微软封装的这些application \session\profile\membership可伸缩性太差,而且在集群使用时很麻烦,所以:

1、只使用Coookie识别用户;Membership完全根据Cookie机制自定义,要多灵活有多灵活。
2、application/session/profile等,完全用自己编写的Cache代替。

[解决办法]

探讨
终极答案:

傻逼才会使用application \session\profile\membership....等等一切微软封装的

Web开发,只需要使用html/js等,微软封装的这些application \session\profile\membership可伸缩性太差,而且在集群使用时很麻烦,所以:

1、只使用Coookie识别用户;Membership完全根据Cookie……

热点排行