|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
ASP是依赖组件的,能访问数据库的组件好多就有好多种,再有就是你微软的工具可是什么都要收钱的啊!<%@PageLanguage="VB"%>
<scriptlanguage="VB"runat="server">
ConstCOOKIE_NAMEAsString="test-cookie-name"
ConstCOOKIE_VALUEAsString="test-cookie-value"
Declareourcookieobject
DimobjCookieObjectAsHttpCookie
SubbtnSetCookie_OnClick(SenderAsObject,EAsEventArgs)
Createacookieobject-Impassingnameandvalue,
butyoucanalsopassinanameandsetthevaluelater.
ie.objCookieObject=NewHttpCookie(COOKIE_NAME)
objCookieObject=NewHttpCookie(COOKIE_NAME,COOKIE_VALUE)
Wealreadysettheseabove!
objCookieObject.Name=COOKIE_NAME
objCookieObject.Value=COOKIE_VALUE
Additionalcookieproperties:
objCookieObject.Expires=NewDateTime(2001,12,31,23,59,59)
Normallyyoucanleavethesealone.
Thedefaultswillworkfineformostuses.
objCookieObject.Domain="www.domain.com"
objCookieObject.Path="/path/"
objCookieObject.Secure=True
Response.AppendCookie(objCookieObject)
EndSub
SubbtnRemoveCookie_OnClick(SenderAsObject,EAsEventArgs)
objCookieObject=NewHttpCookie(COOKIE_NAME)
ExpireitonthedayIwasbornjustsoweresureitsadateinthepast.
objCookieObject.Expires=NewDateTime(1974,11,12)
Response.AppendCookie(objCookieObject)
EndSub
SubbtnGetCookie_OnClick(SenderAsObject,EAsEventArgs)
objCookieObject=Request.Cookies(COOKIE_NAME)
IfNot(objCookieObject=null)Then
lblCookieDetails.Text=objCookieObject.Name
lblCookieDetailsName.Text=objCookieObject.Name
lblCookieDetailsValue.Text=objCookieObject.Value
lblCookieDetailsExpires.Text=objCookieObject.Expires.ToString
lblCookieDetailsDomain.Text=objCookieObject.Domain
lblCookieDetailsPath.Text=objCookieObject.Path
lblCookieDetailsSecure.Text=objCookieObject.Secure.ToString
lblCookieDetailsHasKeys.Text=objCookieObject.HasKeys.ToString
Else
lblCookieDetails.Text="CookieNotSet!"
lblCookieDetailsName.Text=""
lblCookieDetailsValue.Text=""
lblCookieDetailsExpires.Text=""
lblCookieDetailsDomain.Text=""
lblCookieDetailsPath.Text=""
lblCookieDetailsSecure.Text=""
lblCookieDetailsHasKeys.Text=""
EndIf
Imignoringcollections.Theyreoutsidetherealmofthisbasicsample.
FYI:Additionalpropertiesrelatedtocookiecollections:Values,Item
EndSub
</script>
<html>
<body>
<h4>Thecookienamewereusingforthissampleis:<em><%=COOKIE_NAME%></em></h4>
<formaction="cookies.aspx"method="post"runat="server">
<asp:Buttontype="submit"id="btnSetCookie"text="SetCookie"
runat="server"/>
<asp:Buttontype="submit"id="btnRemoveCookie"text="RemoveCookie"
runat="server"/>
<p>
Toseethecookiescurrentstatusyoullneedtoclickbelow.Thisisbecausetheresponse
whichaddsordeletesthecookiehappensaftertherequestisalreadydone.Assuch,thosechangesarent
availablefromtherequestcollectionuntilthenextrequest.
</p>
<asp:Buttontype="submit"id="btnGetCookie"text="GetCookieDetails"
runat="server"/>
</form>
<p>
<strong>Detailsof:</strong><asp:labelid="lblCookieDetails"runat="server"/>
</p>
<tableborder="1">
<thead>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Name</td>
<td><asp:labelid="lblCookieDetailsName"runat="server"/></td>
</tr>
<tr>
<td>Value</td>
<td><asp:labelid="lblCookieDetailsValue"runat="server"/></td>
</tr>
<tr>
<td>Expires</td>
<td><asp:labelid="lblCookieDetailsExpires"runat="server"/></td>
</tr>
<tr>
<td>Domain</td>
<td><asp:labelid="lblCookieDetailsDomain"runat="server"/></td>
</tr>
<tr>
<td>Path</td>
<td><asp:labelid="lblCookieDetailsPath"runat="server"/></td>
</tr>
<tr>
<td>Secure</td>
<td><asp:labelid="lblCookieDetailsSecure"runat="server"/></td>
</tr>
<tr>
<td>HasKeys</td>
<td><asp:labelid="lblCookieDetailsHasKeys"runat="server"/></td>
</tr>
</tbody>
</table>
</body>
</html>
使用filesystemobject,可以对服务器上的文件进行操作,浏览、复制、移动、删除等。有ado的支持,asp对数据库的操作非常得心应手。你甚至可以像使用本地数据库那样,管理远程主机上的数据库,对表格、记录进行各种操作。 |
|