【问题标题】:classic asp getting value of global variable经典asp获取全局变量的值
【发布时间】:2014-01-10 17:30:56
【问题描述】:

我试图只输出 global.asa 应用程序(“SiteURL”),但我什么也没得到 显示为 SiteURL。我在 global.asa 中将其定义为

    <!--METADATA TYPE="TypeLib" FILE="c:\Program Files\Common Files\System\ado\msado15.dll" -->

    <SCRIPT LANGUAGE="VBScript"  RUNAT="Server">
       Sub Application_OnStart
          Application("SiteURL") = "http://[localhost]/asp3test/" 
          Application("myAppVariable") = "Apple" 
          Application("CurrentDateTime") = ""  
       End Sub
   </SCRIPT>

这是我的 test.asp 文件:

 <BODY>
 Let's retrieve the values of the Application Variables:<P>
 myAppVariable = <%= Application("myAppVariable")%><BR>
 SiteURL = <%= Application("SiteURL")%> <br />
 CurrentDateTime = <%= Application("CurrentDateTime")%><br />

 Now, let's set the variables:<HR>
 <%
 Application.Lock
 Application("CurrentDateTime") = Now
 Application.UnLock
 %>
 Variables set - <A HREF="test.asp">click here</A> to reload the page to view
 </BODY>

结果:

Let's retrieve the values of the Application Variables:

myAppVariable =
SiteURL =
CurrentDateTime = 12/22/2013 1:47:42 PM
Now, let's set the variables:

Global.asa文件中设置的值好像没有被抓取,喜欢 没有被读取(处理),但是当我手动将值设置为应用程序(变量)时,它似乎保留了它。所以 Global.asa 缺少的东西没有被阅读。我使用的是 IIS 7.5.76 和 Win7(64 位),不确定是否有帮助。

【问题讨论】:

  • 我已删除 ASP.NET 标记。 ASP.NET 和 Classic ASP是一回事。

标签: asp-classic


【解决方案1】:

我的网站设置不正确...我必须将应用程序添加到默认网站才能正常工作。它之前不起作用的原因是因为我只创建了一个与默认网站分开的网站,并且没有将应用程序添加到该网站。但是,尝试在 IIS 中创建添加应用程序时出现错误。我在某处听说这是一个错误。这让我大吃一惊。

【讨论】:

    【解决方案2】:

    您是否在您的global.asa 中正确的Sub 中找到了它?即

    Sub Application_OnStart
        Application("SiteURL") = "http://[localhost]/asp3test/"
    End Sub
    

    【讨论】:

    • 我添加了一些附加信息。但是,是的,它们在 global.asa 中
    • test.asp 在虚拟服务器的根目录中?
    • 我在某处看到我需要更改 IIS 上的应用程序目录的名称? stackoverflow.com/questions/1427779/…
    • 如果test.asp在有自己的应用程序的目录中,那么它不能访问根应用程序的变量。
    • 没有文件夹。该网站的所有文件都位于同一根目录下。我想知道我是否配置正确?
    猜你喜欢
    • 1970-01-01
    • 2011-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多