Background
Application/Program: lightweight website (40,000 HTML pages | 5 .ASPX
pages).
Goal: use application variables (.NET
) ~ via Global.asax
Problem: web server is failing to use application variables (yet dev environment is fine)
Desire: web server uses application variables
Tech Specs
.ASPX
webforms; Visual BasicDetails
In my development environment, my application variables are working fine (ie, 100% success rate)
On my web server, though, my application variables are failing (0% success rate)
Code - Global.asax.vb
:
Sub Application_Start(sender As Object, e As EventArgs)
Application("fooBar") = "Hello, World"
End Sub
MyPage.aspx
:
<script runat="server">
Protected Function EmbedMe() As String
Return Application("fooBar")
End Function
</script>
<nav><%: EmbedMe() %></nav>
Troubleshooting
So far, I've tried to solve my problem in the following ways:
Global.asax
file [on the web server][on the web server] (eg,
obj*;
packages*`; etc.)Request
May you please help me get my web server to respect/use my .NET
application variables?
Thanks
Place the following three files onto the webserver:
~/bin/App_global.asax.compiled
~/bin/App_global.asax.dll
~/PrecompiledApp.config
The real problem was that my Web Server
was not executing Application_Start()
. The reason it wasn't firing was, apparently, because my Web Server
was not running my Global.asax
file.
My web server was missing three files:
~/bin/App_global.asax.compiled
~/bin/App_global.asax.dll
~/PrecompiledApp.config
Reason: I presume that it was missing those files because I don't use VS2019's Publish
functionality. Instead, I just: (i) compile my website application; and (ii) copy my files onto my webserver (via a [selective] batch file).
You will probably need to recycle
the ApplicationPool
on your WebServer
!! For me – despite adding those files – my web server [still] wouldn't fire the Application_Start()
routine (and, thus, create my Application Variables
) until I recycled
my ApplicationPool
¹ small note: apparently, it doesn't matter if those three [aforementioned] files are very outdated. My files had timestamps from 4 years ago, yet all of my updates were working.
² smaller note: apparently, the web server doesn't need these three files in order to execute your .aspx
and/or .html
files properly.
Just copy those three files onto your webserver and you should start seeing your Application Variables
on your website/webapp (all [other] things being equal, of course).
I hope this can help you.
Best Wishes.