可参考:http://zhidao.baidu.com/question/139870677.html
待考证:
asp.net 一个页面只允许一个客户访问
用web.config来进行
------------------------------------------------------------
登录研制,可使用基类继承,然后只需判断一次即可;不用每个页面去写判断
继承basepage啊 百度BasePage即可;
<!--StartFragment -->
码仔(281242495) 16:55:26
大家做系统时候。 一般用什么做验证用户登陆。 WebConfig. 还是通过Session来控制?
ahua501(52825258) 16:59:21
Session
空心菜<zilong_1@sina.com> 16:59:45
Session or cookies
码仔(281242495) 17:00:10
不是web.Config直接配置 <authentication mode="Forms">
<forms loginUrl="Login.aspx" name=".ASPXAUTH"></forms>
</authentication>
码仔(281242495) 17:00:31
<authorization><deny users="?"></deny></authorization>
码仔(281242495) 17:00:42
那种比较好点?
天涯孤客(234429300) 17:00:46
一般的网站就COOKIE 要是重要的 网站 如卖东西 我喜欢 SESSION + COOKIE
码仔(281242495) 17:01:18
难道每个页面都的去判断?
风神 17:01:31
是要这样吧
风神 17:01:44
用web.config就不用每个页面去判断了吗?
空心菜<zilong_1@sina.com> 17:01:45
继承basepage啊
码仔(281242495) 17:01:46
还是写个页面基类。 继承这个基类.
空心菜<zilong_1@sina.com> 17:01:59
为什么要写在每个要面上?
码仔(281242495) 17:02:09
用webconfig 不需要每个写
风神 17:02:26
页面基类?
风神 17:02:33
是.cs吧?
飘逸随流云<zhanzi124@qq.com> 17:02:34
继承好
风神 17:02:40
aspx能继承么?
ahua501(52825258) 17:02:50
写了dll就好了
空心菜<zilong_1@sina.com> 17:02:51
说实话 我out了 我做了几年 重木有在webconfig 做验证
飘逸随流云<zhanzi124@qq.com> 17:03:13
webconfig里面的配置看着都恼火
ahua501(52825258) 17:03:25
然后传递page值
码仔(281242495) 17:03:26
我三年没搞bs了。。 现在没办法 做bs
空心菜<zilong_1@sina.com> 17:03:44
一看一大堆 乱的很 在加上自己的httphander 又是一大堆
天涯孤客(234429300) 17:03:53
webconfig的意思是 必须从莫个页面开始运行
空心菜<zilong_1@sina.com> 17:04:53
反正我没用过那种方法 不晓的。。
ahua501(52825258) 17:04:59
Page
码仔(281242495) 17:05:01
哪个安全点。。 貌似Session这东西 不怎么好控制
风神 17:07:54
基类继承这个怎么弄啊?
编程浪子(99954486) 17:10:43
写个基类
统一在基类中验证吧
ahua501(52825258) 17:14:15
page 变量
写成一个类,然后页面就去调用这个类就好了
public void ffdl1(Page p,string yzfs,string ymmc,string ts,string qbzd)//验证非法登陆,ymmc页面名称,ts提示,qbzd区别字段
{
string myurl = "";
if (wzurl == "")
{
return;
}
/*string ssname="yhid";
{
string myurl = "";
if (wzurl == "")
{
return;
}
/*string ssname="yhid";
if (qbzd != "" && qbzd!=null)
{
ssname = qbzd;
}*/
{
ssname = qbzd;
}*/
if (p.Session["loginxt"] == null || p.Session["yhid"]==null)
{
if (yzfs=="1")
{
myurl = wzurl + "/admin/gdym.aspx";
p.Response.Redirect(myurl + "?tzfs=zj&errorinfo="+p.Server.UrlEncode("使用时间已经超过有效期,请重新登陆!"));
}
else if(yzfs=="2")
{
myurl = wzurl + "/" + ymmc;
p.Response.Redirect(myurl+"?errorinfo="+p.Server.UrlDecode(ts));
{
myurl = wzurl + "/admin/gdym.aspx";
p.Response.Redirect(myurl + "?tzfs=zj&errorinfo="+p.Server.UrlEncode("使用时间已经超过有效期,请重新登陆!"));
}
else if(yzfs=="2")
{
myurl = wzurl + "/" + ymmc;
p.Response.Redirect(myurl+"?errorinfo="+p.Server.UrlDecode(ts));
/*myurl = "top.location.replace(\"" + myurl + "?errorinfo=使用时间已经超过有效期,请重新登陆!\");";
ClientScriptManager cs = p.Page.ClientScript;
Type cstype = this.GetType();
cs.RegisterStartupScript(cstype, "Startup", myurl, true);*/
}
else if (yzfs == "3")
{
myurl = wzurl + "/admin/gdym.aspx";
p.Response.Redirect(myurl + "?tzfs=gb&errorinfo=" + p.Server.UrlEncode("使用时间已经超过有效期,请重新登陆!"));
ClientScriptManager cs = p.Page.ClientScript;
Type cstype = this.GetType();
cs.RegisterStartupScript(cstype, "Startup", myurl, true);*/
}
else if (yzfs == "3")
{
myurl = wzurl + "/admin/gdym.aspx";
p.Response.Redirect(myurl + "?tzfs=gb&errorinfo=" + p.Server.UrlEncode("使用时间已经超过有效期,请重新登陆!"));
}
}
}
}