[ 登录 ]
欢迎您, <%= UInFo %>[ ]
网站登陆后:
因为流程需要,不能通过点击注销来实现登出,也就因为这样视图还是登陆后的样子,我找了半天都没找到后台切换loginview视图的办法,或许有,但我不知道。。
ps:复制党就别来了。
该问题已经解决。通过formauthxxxxx.xx就可以删除当前已经登录表单。原理是,实际上以上控件使用的登录方法来自formauthxxxx.sign。
直接使用估计是够呛了,用Relfector反编译以后发现它的TempleteIndex是通过访问IPrincipal来确定的,并且没有提供public的方法来更改这个属性。
我觉得可行的办法是重写LoginView控件的CreateChildControls,反编译的内容。
protected internal override void CreateChildControls()
{
this.Controls.Clear();
Page page = this.Page;
if (((page != null) && !page.IsPostBack) && !base.DesignMode)
{
this._templateIndex = this.GetTemplateIndex();
}
int templateIndex = this.TemplateIndex;
ITemplate anonymousTemplate = null;
switch (templateIndex)
{
case 0:
anonymousTemplate = this.AnonymousTemplate;
break;
case 1:
anonymousTemplate = this.LoggedInTemplate;
break;
default:
{
int num2 = templateIndex - 2;
RoleGroupCollection roleGroups = this.RoleGroups;
if ((0 <= num2) && (num2 < roleGroups.Count))
{
anonymousTemplate = roleGroups[num2].ContentTemplate;
}
break;
}
}
if (anonymousTemplate != null)
{
Control container = new Control();
anonymousTemplate.InstantiateIn(container);
this.Controls.Add(container);
}
}