C#如何进行用户识别? 当用户通过登录界面登录,登录后登录界面关闭,进入主系统界面,主系统怎么识别登录的用户?请各位高手帮帮忙! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 参数传递,通过XML等实现保存web中session 登录界面是主系统界面让它show出来的吧?登录界面总要通知主系统界面登录结果吧?(登录了还是取消了)这就是事件通知。简单从逻辑上来说,主系统程序往往是类似这样的static string 谁登录了=null;void main(){ LoginForm loginForm = new LoginFormV2(); loginForm.登录事件 += (s,e)=> { 谁登录了= e.登录人; this.显示登录后的界面(); } loginForm.取消登录事件 += (s,e) =>{ 谁登录了= null; this.显示登录前的界面(); }; loginForm.Show();}既主系统中的一个static变量保存进程登录信息,而main只是让登录界面显示出来而已,程序就结束了。我在demo 中用一个LoginForm界面的子类实例来做Demo,因为登录界面我们可能有多款,根据用户的喜好,反正它们都是继承自LoginForm类,在这个类中定义了两个事件用于通知登录窗体操作结果。对于asp.net,情况复杂一点点。因为每一个页面都是独立的分离的,于是这个“谁登录了”往往使用cookie,而这里的事件导航则往往用页面重定向来实现。 WINFORM中新建一个类 里面添字段 public static int LoginId = 0;然后让点击登录的时候loginId=登录的号码if(loginId!=0){consloe.write("登陆了");}else{console.write("没登陆");} public class Common { private static string userId; private static string userName; public static string UserId { get { return userId; } set { userId = value; } } public static string UserName { get { return userName; } set { userName = value; } } } 赋值 string userid="userid"; string username="username"; Common.UserId = userid; Common.UserName = username; 任何窗体都可以调用 string userid=Common.UserId; string username=Common.UserName; 用session吧 登录的时候把你的用户对象放到session中: session["user"]= user(user是一个对象) 在跳转页后置代码中取出user = (user)session["user"],在做 user的判断既可 3层架构封装,我的这个思路正确吗? 酒店房态图的问题 关于摸拟U盘的问题 请问,在gridcontrol或dategridview中,当绑定了一个表以后,在控件中增加一行的原理或过程是怎样的? 关于 PostMessage 函数的问题 在sql2000中存储过程的表(即各项存储过程)的名字到底应该怎样取才能和整个程序联系起来啊?谢谢! 问一个可能很简单的问题 winform中显示计算结果以及更新到Sql数据库 请问 windowsForm 类中属性怎么使用多遍 [新手请教] 有请高手帮我改错 access时间段查询 C# 里恢复数据库问题
web中session
登录界面是主系统界面让它show出来的吧?登录界面总要通知主系统界面登录结果吧?(登录了还是取消了)这就是事件通知。简单从逻辑上来说,主系统程序往往是类似这样的static string 谁登录了=null;void main()
{
LoginForm loginForm = new LoginFormV2();
loginForm.登录事件 += (s,e)=> { 谁登录了= e.登录人; this.显示登录后的界面(); }
loginForm.取消登录事件 += (s,e) =>{ 谁登录了= null; this.显示登录前的界面(); };
loginForm.Show();
}
既主系统中的一个static变量保存进程登录信息,而main只是让登录界面显示出来而已,程序就结束了。我在demo 中用一个LoginForm界面的子类实例来做Demo,因为登录界面我们可能有多款,根据用户的喜好,反正它们都是继承自LoginForm类,在这个类中定义了两个事件用于通知登录窗体操作结果。
对于asp.net,情况复杂一点点。因为每一个页面都是独立的分离的,于是这个“谁登录了”往往使用cookie,而这里的事件导航则往往用页面重定向来实现。
新建一个类 里面添字段 public static int LoginId = 0;
然后让点击登录的时候loginId=登录的号码
if(loginId!=0){
consloe.write("登陆了");
}else{
console.write("没登陆");
}
{
private static string userId;
private static string userName;
public static string UserId
{
get { return userId; }
set { userId = value; }
}
public static string UserName
{
get { return userName; }
set { userName = value; }
}
}
赋值
string userid="userid";
string username="username";
Common.UserId = userid;
Common.UserName = username;
任何窗体都可以调用
string userid=Common.UserId;
string username=Common.UserName;