为什么Global.asa 不起作用?求助

BlueDog 2004-09-22 08:59:45
我对于ASP编程的确是初哥,最近编了一个Global.asa文件放在IIS的根目录下,其中包括了几个事件
Application_OnStart Application_OnEnd
Session_OnStart

几个事件均进行了测试,当置于ASP中时可以运行。
但为什么我将IIS服务重启后,并且对default.asp进行访问,但是Application_OnStart并没有触发?

百思不得其解,望告
...全文
129 8 打赏 收藏 举报
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zhouhuaian 2004-11-17
请问你这是怎么解决的?我的也是,现在这个文件就不起作用.在这里的创建ORACLE的对象在其它页面都要用.现在突然环境坏了.在重新装这个文件就怎么都不起作用了.急死人了.
以前执行得没问题.
  • 打赏
  • 举报
回复
其实你可以试试hello world之类的东东在global.asa 中看看
  • 打赏
  • 举报
回复
nice90 2004-09-23
好了,你这个里面的<script>必须顶着“<”写,下面是我修改后的global.asa代码和test.asp代码:
global.asa:
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Application_OnStart
DIM VCFN,FileObject,Out
VCFN = Server.MapPath ("/webdata") + "\VisitCount.txt"
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
IF FileObject.FileExists(VCFN) = True THEN
'response.write("Open: " + VCFN +"<BR>")

Set Out= FileObject.OpenTextFile (VCFN, 1, FALSE, FALSE)
Out.SkipLine
Application("visitors") = Out.ReadLine
Out.Close
ELSE
'response.write("Create: " + VCFN +"<BR>")

Set Out= FileObject.CreateTextFile(VCFN)
Out.WriteLine("'Don't changed this file or delete it.")
Out.WriteLine("0")
Application("visitors") = 0
Out.Close
END IF

Application("VisitorCountFilename") = VCFN

'response.write(Application("visitors"))
'response.write(Application("VisitorCountFileName"))
'nice90 had tested this global.asa file.
'Application("MyTest") = "Welcome To This Global.asa"
Set Out =nothing
Set FileObject =nothing
End Sub

'=========================================================
SUB Application_OnEnd
Dim FileObject,Out

Set FileOutObject = Server.CreateObject("Scripting.FileSystemObject")
Application.lock
Set Out= FileOutObject.CreateTextFile (Application("VisitorCountFilename"), TRUE,FALSE)
Out.WriteLine("'Don't changed this file or delete it.")
Out.WriteLine(application("visitors"))
Out.Close
Application.unlock
Set Out =nothing
Set FileObject =nothing
End Sub

'=========================================================
Sub Session_OnStart
Session.Timeout = 30
Application.lock
Application("visitors") = Application("visitors") + 1
Application.unlock
End Sub

</SCRIPT>

Test.asp:
<%
Response.Write Server.MapPath ("/webdata") + "\VisitCount.txt"&"<br>"
Response.Write Application("VisitorCountFilename")&"<br>"
'Response.Write Application("MyTest")
Response.End
%>
  • 打赏
  • 举报
回复
panshiwu 2004-09-22
代码贴出来 看看
  • 打赏
  • 举报
回复
nice90 2004-09-22
give out you global.asa and default.asp code.
  • 打赏
  • 举报
回复
BlueDog 2004-09-22
我是放在站点的根下,比如说我有一个www.test.com
对应c:\inetput\webroot\
我在webroot下放了一个global.asa
但是没有作用。。。。。。
  • 打赏
  • 举报
回复
孟子E章 2004-09-22
Global.asa要放到你虚拟目录的根或者站点根下,不是放在iis根下对所有的站点都起作用的,每个站点或者虚拟目录有自己的Global.asa
  • 打赏
  • 举报
回复
BlueDog 2004-09-22
下面是我的代码,各位老大瞧瞧
< SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Application_OnStart
DIM VCFN,FileObject,Out
VCFN = Server.MapPath ("/webdata") + "\VisitCount.txt"
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
IF FileObject.FileExists(VCFN) = True THEN
'response.write("Open: " + VCFN +"<BR>")

Set Out= FileObject.OpenTextFile (VCFN, 1, FALSE, FALSE)
Out.SkipLine
Application("visitors") = Out.ReadLine
Out.Close
ELSE
'response.write("Create: " + VCFN +"<BR>")

Set Out= FileObject.CreateTextFile(VCFN)
Out.WriteLine("'Don't changed this file or delete it.")
Out.WriteLine("0")
Application("visitors") = 0
Out.Close
END IF

Application("VisitorCountFilename") = VCFN

'response.write(Application("visitors"))
'response.write(Application("VisitorCountFileName"))
Set Out =nothing
Set FileObject =nothing
End Sub

'=========================================================
SUB Application_OnEnd
Dim FileObject,Out

Set FileOutObject = Server.CreateObject("Scripting.FileSystemObject")
Application.lock
Set Out= FileOutObject.CreateTextFile (Application("VisitorCountFilename"), TRUE,FALSE)
Out.WriteLine("'Don't changed this file or delete it.")
Out.WriteLine(application("visitors"))
Out.Close
Application.unlock
Set Out =nothing
Set FileObject =nothing
End Sub

'=========================================================
Sub Session_OnStart
Session.Timeout = 0
Application.lock
Application("visitors") = Application("visitors") + 1
Application.unlock
End Sub

< /SCRIPT>
  • 打赏
  • 举报
回复
相关推荐
发帖
IIS
加入

8280

社区成员

Web 开发 IIS
社区管理员
  • IIS
申请成为版主
帖子事件
创建了帖子
2004-09-22 08:59
社区公告
暂无公告