我有 2-3 个 Web 项目(初学者的)。在所有网站中,我都有一个用户可以登录的登录控件。当用户使用正确的信息登录时,我设置了
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
if (CHUser.AunthencateLogin(Login1.UserName, Login1.Password))//Checks with database
e.Authenticated = true;
else
e.Authenticated = false;
}
到这里还好,但是当我同时登录到 2 个单独的网站(本地),并在其中任何一个注销时,问题就出现了。当我在一个网站注销时,另一个网站也被注销(刷新时)。以下是我在注销时使用的代码。
protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)
{
Session.Clear(); //though logout works without this code. It is for other
//sessions that are manually created by me
}
我看不出是什么原因造成的。我也是网络开发的新手。
我还想知道这是否是登录用户的正确方式。
最佳答案
(在问题编辑中回答。转换为社区维基答案。参见 What is the appropriate action when the answer to a question is added to the question itself?)
OP 写道:
Thanks @Aristos. the problem was solved by using the following code on web.config 1st project
<authentication mode="Forms"> <forms name=".Cookie1" ... /> </authentication>
2nd project
<authentication mode="Forms"> <forms name=".Cookie2" ... /> </authentication>
关于c# - ASP.NET HeadLoginView 注销 单击。也退出其他本地网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12400306/