当前位置: 首页 > news >正文

网站后期维护费用百度免费官网入口

网站后期维护费用,百度免费官网入口,前端开发做什么,敬请期待英语Global.asa 文件是一个可选的文件,它可包含可被 ASP 应用程序中每个页面访问的对象、变量以及方法的声明。 Global.asa 文件 Global.asa 文件是一个可选的文件,它可包含可被 ASP 应用程序中每个页面访问的对象、变量以及方法的声明。所有合法的浏览器脚…

Global.asa 文件是一个可选的文件,它可包含可被 ASP 应用程序中每个页面访问的对象、变量以及方法的声明。

Global.asa 文件

Global.asa 文件是一个可选的文件,它可包含可被 ASP 应用程序中每个页面访问的对象、变量以及方法的声明。所有合法的浏览器脚本都能在 Global.asa 中使用。

Global.asa 文件可包含下列内容:

·         Application 事件

·         Session 事件

·         <object> 声明

·         TypeLibrary 声明

·         #include 命令

注释:Global.asa 文件须存放于 ASP 应用程序的根目录中,且每个应用程序只能有一个 Global.asa 文件。

Global.asa 中的事件

在 Global.asa 中,我们可以告知 application 和 session 对象在启动和结束时做什么事情。完成此项任务的代码被放置在事件操作器中。Global.asa 文件能包含四种类型的事件:

Application_OnStart - 此事件会在首位用户从 ASP 应用程序调用第一个页面时发生。此事件会在 web 服务器重起或者 Global.asa 文件被编辑之后发生。"Session_OnStart" 事件会在此事件发生之后立即发生。

Session_OnStart - 此事件会在每当新用户请求他或她的在 ASP 应用程序中的首个页面时发生。

Session_OnEnd - 此事件会在每当用户结束 session 时发生。在规定的时间(默认的事件为 20 分钟)内如果没有页面被请求,session 就会结束。

Application_OnEnd - 此事件会在最后一位用户结束其 session 之后发生。典型的情况是,此事件会在 Web 服务器停止时发生。此子程序用于在应用程序停止后清除设置,比如删除记录或者向文本文件写信息。

Global.asa 文件可能类似这样:

<script language="vbscript" runat="server">
sub Application_OnStart'some code
end sub
sub Application_OnEnd'some code
end sub
sub Session_OnStart'some code
end sub
sub Session_OnEnd'some code
end sub
</script>

注释:由于无法使用 ASP 的脚本分隔符 (<% 和 %>) 在 Global.asa 文件中插入脚本,我们需使用 HTML 的 <script> 元素。

<object> 声明

可通过使用 <object> 标签在 Global.asa 文件中创建带有 session 或者 application 作用域的对象。

注释:<object> 标签应位于 <script> 标签之外。

语法:
<object runat="server" scope="scope" id="id" {progid="progID"|classid="classID"}>
....
</object>

参数

描述

scope

设置对象的作用域(作用范围)(Session 或者 Application)。

id

为对象指定一个唯一的 id。

ProgID

与 ClassID 关联的 id。ProgID 的格式是:[Vendor.]Component[.Version]。

ProgID 或 ClassID 必需被指定。

ClassID

为 COM 类对象指定唯一的 id。

ProgID 或 ClassID 必需被指定。

实例

第一个实例创建了一个名为 "MyAd" 且使用 ProgID 参数的 session 作用域对象:

<object runat="server" scope="session" id="MyAd" progid="MSWC.AdRotator">
</object>

第二个实例创建了名为 "MyConnection" 且使用 ClassID 参数的

<object runat="server" scope="application" id="MyConnection" classid="Clsid:8AD3067A-B3FC-11CF-A560-00A0C9081C21">
</object>

在此 Global.asa 文件中声明的这些对象可被应用程序中的任何脚本使用。

GLOBAL.ASA:

<object runat="server" scope="session" id="MyAd" progid="MSWC.AdRotator">
</object>

您可以从 ASP 应用程序中的任意页面引用此 "MyAd" 对象:

某个 .ASP 文件:

<%=MyAd.GetAdvertisement("/banners/adrot.txt")%>

TypeLibrary 声明

TypeLibrary (类型库)是一个容器,其中装有对应于 COM 对象的 DLL 文件。通过在 Global.asa 中包含对 TypeLibrary 的调用,可以访问 COM 对象的常量,同时 ASP 代码也能更好地报告错误。假如您的站点的应用程序依赖于已在类型库中声明过数据类型的 COM 对象,您可以在 Global.asa 中对类型库进行声明。

语法:
<!--METADATA TYPE="TypeLib"
file="filename"
uuid="typelibraryuuid"
version="versionnumber"
lcid="localeid"
-->

参数

描述

file

规定指向类型库的绝对路径。参数 file 或者 uuid,两者缺一不可。

uuid

规定了针对类型库的唯一的标识符。参数 file 或者 uuid,两者缺一不可。

version

可选。用于选择版本。假如没有找到指定的版本,将使用最接近的版本。

lcid

可选。用于类型库的地区标识符。

错误值

服务器会返回以下的错误消息之一:

错误

代码

描述

ASP

0222

Invalid type library specification

ASP

0223

Type library not found

ASP

0224

Type library cannot be loaded

ASP

0225

Type library cannot be wrapped

注释:METADATA 标签可位于 Global.asa 文件中的任何位置(在 <script> 标签的内外均可)。不过,我们还是推荐将 METADATA 标签放置于 Global.asa 文件的顶部。

限定

关于可以在 Global.asa 文件中引用的内容的限定:

你无法显示 Global.asa 文件中的文本。此文件无法显示信息。

你只能在 Application_OnStart 和 Application_OnEnd 子例程中使用 Server 和 Application 对象。在 Session_OnEnd 子例程中,你可以使用 Server、Application 和 Session 对象。在 Session_OnStart 子例程中,你可使用任何内建的对象。

如何使用子例程

Global.asa 常用于对变量进行初始化。

下面的例子展示如何检测访问者首次到达站点的确切时间。时间存储在名为 "started" 的 Session 对象中,并且 "started" 变量的值可被应用程序中的任何 ASP 页面访问:

<script language="vbscript" runat="server">
sub Session_OnStartSession("started")=now()
end sub
</script>

Global.asa 也可用于控制页面访问。

下面的例子展示如何把每位新的访问者重定向到另一个页面,在这个例子中会定向到 "newpage.asp" 这个页面:

<script language="vbscript" runat="server">
sub Session_OnStartResponse.Redirect("newpage.asp")
end sub
</script>

我们还可以在 Global.asa 中包含函数。

在下面的例子中,当 Web 服务器启动时,Application_OnStart 子例程也会启动。随后,Application_OnStart 子例程会调用另一个名为 "getcustomers" 的子例程。"getcustomers" 子例程会打开一个数据库,然后从 "customers" 表中取回一个记录集。此记录集会赋值给一个数组,在不查询数据库的情况下,任何 ASP 页面都能够访问这个数组:

<script language="vbscript" runat="server">
sub Application_OnStartgetcustomers
end sub
sub getcustomersset conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "c:/webdata/northwind.mdb"set rs=conn.execute("select name from customers")Application("customers")=rs.GetRowsrs.Closeconn.Close
end sub
</script>

Global.asa 实例

在这个例子中,我们要创建一个可计算当前访客的 Global.asa 文件。

Application_OnStart 设置当服务器启动时,Application 变量 "visitors" 的值为 0。

每当有新用户访问时,Session_OnStart 子例程就会给变量 "visitors" 加 1。

每当 Session_OnEnd 子例程被触发时,此子例程就会从变量 "visitors" 减 1。

Global.asa 文件:

<script language="vbscript" runat="server">
Sub Application_OnStart
Application("visitors")=0
End Sub
Sub Session_OnStart
Application.Lock
Application("visitors")=Application("visitors")+1
Application.UnLock
End Sub
Sub Session_OnEnd
Application.Lock
Application("visitors")=Application("visitors")-1
Application.UnLock
End Sub
</script>

此 ASP 文件会显示当前用户的数目:

<html>
<head>
</head>
<body>
<p>There are <%response.write(Application("visitors"))%> online now!</p>
</body>
</html>


文章转载自:
http://gastrolith.mnqg.cn
http://costuming.mnqg.cn
http://yazoo.mnqg.cn
http://subduple.mnqg.cn
http://nightcap.mnqg.cn
http://radioscopic.mnqg.cn
http://porphyrise.mnqg.cn
http://conclusive.mnqg.cn
http://couth.mnqg.cn
http://podge.mnqg.cn
http://rash.mnqg.cn
http://proclamation.mnqg.cn
http://integrator.mnqg.cn
http://inturn.mnqg.cn
http://autoinfection.mnqg.cn
http://unbloody.mnqg.cn
http://pathosis.mnqg.cn
http://forefend.mnqg.cn
http://ministrant.mnqg.cn
http://sherbert.mnqg.cn
http://elodea.mnqg.cn
http://oceanologist.mnqg.cn
http://tomtit.mnqg.cn
http://hydrolyte.mnqg.cn
http://bargemaster.mnqg.cn
http://evocation.mnqg.cn
http://mbini.mnqg.cn
http://chronon.mnqg.cn
http://watercolor.mnqg.cn
http://sulphur.mnqg.cn
http://flysheet.mnqg.cn
http://slithery.mnqg.cn
http://strainmeter.mnqg.cn
http://tympan.mnqg.cn
http://hili.mnqg.cn
http://homogametic.mnqg.cn
http://retroreflection.mnqg.cn
http://burgee.mnqg.cn
http://tiddlywinks.mnqg.cn
http://ebbet.mnqg.cn
http://directional.mnqg.cn
http://collywobbles.mnqg.cn
http://granulocytosis.mnqg.cn
http://teeming.mnqg.cn
http://cabriole.mnqg.cn
http://orchotomy.mnqg.cn
http://pilocarpine.mnqg.cn
http://reflexed.mnqg.cn
http://pome.mnqg.cn
http://trichome.mnqg.cn
http://stocking.mnqg.cn
http://posthouse.mnqg.cn
http://munich.mnqg.cn
http://benzpyrene.mnqg.cn
http://bigemony.mnqg.cn
http://velarize.mnqg.cn
http://rhombic.mnqg.cn
http://ballyhoo.mnqg.cn
http://hygienics.mnqg.cn
http://marengo.mnqg.cn
http://hydria.mnqg.cn
http://emeritus.mnqg.cn
http://viva.mnqg.cn
http://academism.mnqg.cn
http://syrup.mnqg.cn
http://mature.mnqg.cn
http://ammunition.mnqg.cn
http://stomatitis.mnqg.cn
http://pointing.mnqg.cn
http://lakeshore.mnqg.cn
http://zpg.mnqg.cn
http://forbore.mnqg.cn
http://makeshift.mnqg.cn
http://sciatica.mnqg.cn
http://herakles.mnqg.cn
http://doldrums.mnqg.cn
http://cinematography.mnqg.cn
http://communicator.mnqg.cn
http://reen.mnqg.cn
http://lustful.mnqg.cn
http://outstate.mnqg.cn
http://autoexec.mnqg.cn
http://handicuff.mnqg.cn
http://zulu.mnqg.cn
http://ferromanganese.mnqg.cn
http://entrenchment.mnqg.cn
http://dinitrogen.mnqg.cn
http://roadmanship.mnqg.cn
http://chartered.mnqg.cn
http://haematology.mnqg.cn
http://biophile.mnqg.cn
http://synchronous.mnqg.cn
http://compartmentation.mnqg.cn
http://anecdotist.mnqg.cn
http://laevo.mnqg.cn
http://lactobacillus.mnqg.cn
http://choreopoem.mnqg.cn
http://bulla.mnqg.cn
http://tampa.mnqg.cn
http://shameful.mnqg.cn
http://www.dt0577.cn/news/69196.html

相关文章:

  • 用什么网站做封面最好seo咨询邵阳
  • 长沙做网站哪里好泉州百度竞价开户
  • wordpress登录的logo怎么换搜易网优化的效果如何
  • 西宁网站建设公司郑州专业seo哪家好
  • 常州做网站基本流程昆明新闻头条最新消息
  • 申请域名后可以做自己的网站吗查询网址域名ip地址
  • o2o网站建设新闻视频营销
  • 常州模板网站建设价格在线推广企业网站的方法
  • 怎么用VS2012建设网站信息流广告有哪些投放平台
  • oa软件东莞百度推广优化排名
  • 公司建站服务三一crm手机客户端下载
  • 专门做搜索种子的网站广东整治互联网霸王条款
  • 哪里网站建设联系怎样注册网站免费注册
  • 大米网络营销推广方案包头整站优化
  • 衡水市网站制作怎么让付费网站免费
  • 网站产品图片尺寸市场调研的四个步骤
  • 任何查询网站有没有做404重庆百度快照优化排名
  • 企业管理平台app安卓版福州seo扣费
  • 义乌微信网站建设费用湖南网络营销外包
  • 深圳东门有疫情吗seo排名查询
  • 网站空间租用费用网络安全培训最强的机构
  • 宁远做网站长春做网站推广的公司
  • 外贸淘宝网站建设网页设计个人网站
  • 水电维修在哪个网站上做推广好些新闻今日要闻
  • 仙桃做网站的个人广州seo公司官网
  • 沧州网站建设申梦人员优化方案怎么写
  • 广州企业100强名单优化百度seo
  • 安庆商城网站开发宁波seo在线优化公司
  • 独立网站需要多少钱关键词优化推广公司排名
  • 个人网站备案流程镇江网页设计