Reputation: 14145
Inside my local publish folder I have Global.asax
and Global.asax.cs
where Global.asax is not updated (dated one month ago) and Global.asax.cs is updated.
I check the "Build action" of the Global.asax
file which is set to "Content" and Copy always in the file properties.
How to update global.asax together with global.asax.cs on publish command?
Upvotes: 4
Views: 4046
Reputation: 156928
Global.asax
doesn't usually change. Global.asax
is compiled into a class deriving from the Global
class in your Global.asax.cs
.
You don't have to do anything for that. The server's compiler will pick it up itself. You just need to copy the Global.asax
to your production server, where the Global.asax.cs
will be compiled into an assembly.
Upvotes: 5
Reputation: 172378
See the MSDN:
At run time, Global.asax is parsed and compiled into a dynamically generated .NET Framework class derived from the HttpApplication base class. The Global.asax file itself is configured so that any direct URL request for it is automatically rejected; external users cannot download or view the code written within it.
So as Patrick has already mentioned, there is no need to change it. The compiler will pick it.
When you save changes to an active Global.asax file, the ASP.NET page framework detects that the file has been changed. It completes all current requests for the application, sends the Application_OnEnd event to any listeners, and restarts the application domain. In effect, this reboots the application, closing all browser sessions and flushing all state information. When the next incoming request from a browser arrives, the ASP.NET page framework reparses and recompiles the Global.asax file and raises the Application_OnStart event.
Upvotes: 2