查过MSDN与google,没有答案
以下是重写
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
{ string username = HttpContext.Current.Session["name"] == null ? (string)context["UserName"] : HttpContext.Current.Session["name"].ToString();
bool isAuthenticated = (bool)context["IsAuthenticated"];
//其他省略.....3个问题
1:我调试的时候(string)context["UserName"] 的值为 PC-200901171137\Administrator(计算机名\我系统用户名),当我正常运行的时候它显示是 类似 b0e427d8-f20c-4348-8b86-52bb16b7387d 为什么?2:如果我做一个购物车,只要是匿名登录,匿名用户一直 b0e427d8-f20c-4348-8b86-52bb16b7387d ,所以只要我每次不登陆都可以看见购物车的商品,那么当我 登陆以后,删掉此匿名用户,当下次再匿名访问的时候,它就重新生成类似cb3102cb-3fce-40fb-a5ee-8dd89e8ca476! (string)context["UserName"]到底是怎样实现上面的没登陆一直是同一个匿名用户,而删掉后又重新生成一个匿名用户,它是怎么实现的?
3:Global.asax文件的void Profile_MigrateAnonymous(Object sender, ProfileMigrateEventArgs e)到底是什么时候触发的?
以下是重写
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
{ string username = HttpContext.Current.Session["name"] == null ? (string)context["UserName"] : HttpContext.Current.Session["name"].ToString();
bool isAuthenticated = (bool)context["IsAuthenticated"];
//其他省略.....3个问题
1:我调试的时候(string)context["UserName"] 的值为 PC-200901171137\Administrator(计算机名\我系统用户名),当我正常运行的时候它显示是 类似 b0e427d8-f20c-4348-8b86-52bb16b7387d 为什么?2:如果我做一个购物车,只要是匿名登录,匿名用户一直 b0e427d8-f20c-4348-8b86-52bb16b7387d ,所以只要我每次不登陆都可以看见购物车的商品,那么当我 登陆以后,删掉此匿名用户,当下次再匿名访问的时候,它就重新生成类似cb3102cb-3fce-40fb-a5ee-8dd89e8ca476! (string)context["UserName"]到底是怎样实现上面的没登陆一直是同一个匿名用户,而删掉后又重新生成一个匿名用户,它是怎么实现的?
3:Global.asax文件的void Profile_MigrateAnonymous(Object sender, ProfileMigrateEventArgs e)到底是什么时候触发的?
=============
会不会有给这个值赋值的情况
public void Profile_OnMigrateAnonymous(object sender,ProfileMigrateEventArgs args)
{
//Get anonymous profile
ProfileCommon anonProfile = Profile.GetProfile(args.AnonymousID);//Copy anonymous properties to authenticated
foreach(SettingsProperty prop in ProfileBase.Properties)
{
Profile[prop.Name]=anonProfile[prop.Name];
}//Kill the anonymous profile
ProfileManager.DeleteProfile(args.AnonymousID);
AnonymousIdentificationModule.ClearAnonymousIdentifier();
}
如果不销毁匿名标识,则MigrateAnonymous事件在登录验证后的每次页面请求都会被执行。