|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
由于ASP提供的是一对多的服务,所以用户的一些特殊需求很难得到满足。session|变量|数组IfyoustoreanarrayinaSessionobject,youshouldnotattempttoaltertheelementsofthestoredarraydirectly.Forexample,thefollowingscriptwillnotwork:
<%Session("StoredArray")(3)="newvalue"%>
ThisisbecausetheSessionobjectisimplementedasacollection.ThearrayelementStoredArray(3)doesnotreceivethenewvalue.Instead,thevalueisindexedintothecollection,overwritinganyinformationstoredatthatlocation.
ItisstronglyrecommendedthatifyoustoreanarrayintheSessionobject,youretrieveacopyofthearraybeforeretrievingorchanginganyoftheelementsofthearray.Whenyouaredonewiththearray,youshouldstorethearrayintheSessionobjectagainsothatanychangesyoumadearesaved.Thisisdemonstratedinthefollowingexample:
---file1.asp---
<%
Creatingandinitializingthearray
DimMyArray()
RedimMyArray(5)
MyArray(0)="hello"
MyArray(1)="someotherstring"
StoringthearrayintheSessionobject.
Session("StoredArray")=MyArray
Response.Redirect("file2.asp")
%>
---file2.asp---
<%
RetrievingthearrayfromtheSessionObject
andmodifyingitssecondelement.
LocalArray=Session("StoredArray")
LocalArray(1)="there"
Printingoutthestring"hellothere."
Response.Write(LocalArray(0)&LocalArray(1))
Re-storingthearrayintheSessionobject.
ThisoverwritesthevaluesinStoredArraywiththenewvalues.
Session("StoredArray")=LocalArray
%>
</p>ASP由于使用了COM组件所以它会变的十分强大,但是这样的强大由于WindowsNT系统最初的设计问题而会引发大量的安全问题。只要在这样的组件或是操作中一不注意,哪么外部攻击就可以取得相当高的权限而导致网站瘫痪或者数据丢失; |
|