0

I'm trying to make the following a variable in my global.asa.

<p>abc
    <% If Request.ServerVariables("url") <> "/mobile.asp" Then %><a class="desk" href="/Photos/E.jpg"><% End If %>def<% If Request.ServerVariables("url") <> "/mobile.asp" Then %></a><% End If %>, 
    ghi.</p>

My syntax must be off since it's not taking. Or is there a better way of doing this? Basically, I want to include an html snippet with some asp code without resorting to an #Include file. I'm using asp classic. Thanks.

testing123
  • 761
  • 6
  • 13
  • 37
  • As Shadow Wizard mentioned below you can't put HTML in the global.asa because it's not a file that renders output to the browser. I'm not sure what your desired intent is but based on what I see you would want to locate that code to a .asp file – Gary Richter May 03 '16 at 20:02

1 Answers1

1

You can't have HTML in the global.asa but only events, objects, and setting global scoped variables.

As it says in the official documentation: (emphasis mine)

The Global.asa file is an optional file in which you can specify event scripts and declare objects that have session or application scope. It is not for content that is displayed to clients; instead it stores event information and objects used globally by the application. This file must be named Global.asa and must be stored in the root directory of the application. An application can only have one Global.asa file.

You can't have a file that is automatically included in any page, your best option is just saving the contents (with the if then statements) with .asp or .inc extension, and include it in your pages:

<!-- #include virtual ="/myapp/CheckMobile.inc" --> 
Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208