仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1558|回复: 9
打印 上一主题 下一主题

[学习教程] ASP网站制作之代码例子 - Ask For Login

[复制链接]
透明 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 23:22:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
大家可以自己去看一看.可以说看得想呕吐.以前有次下了个动网来看.里面连基本内置函数的保护措施(函数没防御性)都没有.难怪经常补这个补那个了.可能现在.NET版会好点吧Theneedforasecuritysystemisobviousifyourpagesincludesensitiveinformation.

Thissampleshowsyouhowtosetupsomeofyourpagestoaskforloginiftheuserhasnotloggedinyet.

2eNetWorX/devsiteusesthiskindofprotectionforinteractivepagesandfiledownloads.

Letsassumethatwehaveapagewherethevisitorscanaskquestions.Wewanttomakesurethattheuser
hasloggedinbeforebeingabletoaskaquestion.

Iftheuserhasnotloggedinyet,wewillaskforalogin.Afterasuccessfullogin,wewillredirectthe
usertothepagerequested.

First,wewillhaveacommonfiletocheckforlogin.Youneedtoincludethisfileintoallthepages
thatrequirelogin.

security.asp

<%

bLoggedIn=(len(session("UserName"))>0)

ifbRequireLoginthen
Loginrequired
ifNotbLoggedInthen
Notloggedin,askforlogin
response.redirect"login.asp?comebackto="&_
request.servervariables("script_name")&"?"&_
server.urlencode(request.querystring)
Notehowweconstructthepagetocomeback
endif
endif

%>

login.asp

Firstthingtodoinourlogin.asppageistogetthepagewheretheuserisredirectedfrom.Thevariable
sRefererisusedtoredirectbacktothepagetheuserhascomefrom.

sGoBackTovariablewillusedinthe<form>tagforpersistingthislocationwhenwesubmittheloginform.

<%

ifrequest("comebackto")""then
sReferer=request("comebackto")
sGoBackTo="?"&request.querystring
endif

ifrequest("cmdLogin")""then

LoginFormsubmitted
sUserName=request("txtUserName")
sPassword=request("txtPassword")

Checkforusernameandpassword

ifsUserName="bill"AndsPassword="gates"then
bLoginSuccessful=True
endif

session("UserName")=sUserName


Afterasuccessfullogin,letssendtheuser
backtothepagerequested.ThevariablesReferer
holdsthepagetogoback,ifitisempty,weshould
redirecttheusertoourdefaultpage.

ifsReferer=""then
response.redirect"index.asp"
else
response.redirectsReferer
endif

else

DisplaytheLoginForm

%>

<formaction="login.asp<%=sGoBackTo%>"method="post">
<inputtype="text"name="txtUserName"><br>
<inputtype="password"name="txtPassword"><br>
<inputtype="submit"name="cmdLogin"><br>
</form>

<%

endif

%>

testpage.asp

Now,allyouneedtodoissettingbRequireLogintoTrueandincludingthesecurity.aspfile.

<%

bRequireLogin=True

%>

<!--#includefile="security.asp"-->

Usersshouldbeloggedintoseethistext.

IhopethissamplegivesyouaquickoverviewofasimplesecuritysystemimplementationwithASP.

Youarealwayswelcometoexpressyourfeedback!

byHakanEskici

</p>强大的可扩展性。ASP具有强大的扩展性,可以实现与多种网络、硬件设备的连接:通过专用的通讯线路远程接入企业;通过远程拨号服务器为远程拨号客户提供服务;通过WAP为移动电话互联网客户服务。
若天明 该用户已被删除
沙发
发表于 2015-1-20 09:37:20 | 只看该作者
下面简单介绍一下我学习ASP的方法,希望对想学习ASP的朋友有所帮助...
透明 该用户已被删除
板凳
 楼主| 发表于 2015-1-24 15:08:56 | 只看该作者
你可以通过继承已有的对象最大限度保护你以前的投资。并且C#和C++、Java一样提供了完善的调试/纠错体系。
第二个灵魂 该用户已被删除
地板
发表于 2015-1-29 18:07:28 | 只看该作者
掌握asp的特性而且一定要知道为什么。
若相依 该用户已被删除
5#
发表于 2015-2-2 22:23:34 | 只看该作者
代码逻辑混乱,难于管理:由于ASP是脚本语言混合html编程,所以你很难看清代码的逻辑关系,并且随着程序的复杂性增加,使得代码的管理十分困难,甚至超出一个程序员所能达到的管理能力,从而造成出错或这样那样的问题。
因胸联盟 该用户已被删除
6#
发表于 2015-2-8 14:23:07 | 只看该作者
兴趣爱好,那么你无须学编程,申请一个域名和空间,在网上下载一些免费开源的CMS系统,你不用改代码,只须熟悉它们的后台操作,像office一样简单方便,很快就能建一个站点,很多站长都是这样做的
乐观 该用户已被删除
7#
发表于 2015-2-25 17:34:21 | 只看该作者
掌握asp的特性而且一定要知道为什么。
蒙在股里 该用户已被删除
8#
发表于 2015-3-8 00:23:05 | 只看该作者
代码逻辑混乱,难于管理:由于ASP是脚本语言混合html编程,所以你很难看清代码的逻辑关系,并且随着程序的复杂性增加,使得代码的管理十分困难,甚至超出一个程序员所能达到的管理能力,从而造成出错或这样那样的问题。
小魔女 该用户已被删除
9#
发表于 2015-3-15 17:51:56 | 只看该作者
如何学好ASP,以前也有人问过,把回答给你转过来看看能否对你有帮助:
冷月葬花魂 该用户已被删除
10#
发表于 2015-3-22 02:11:29 | 只看该作者
ASP(ActiveServerPages)是Microsfot公司1996年11月推出的WEB应用程序开发技术,它既不是一种程序语言,也不是一种开发工具,而是一种技术框架,不须使用微软的产品就能编写它的代码,能产生和执行动态、交互式、高效率的站占服务器的应用程序。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2025-3-14 15:58

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表