简体   繁体   English

更新global.asax不仅global.asax.cs

[英]update global.asax not only global.asax.cs

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. 在我的本地发布文件夹中,我有Global.asaxGlobal.asax.cs ,其中Global.asax未更新(日期为一个月),Global.asax.cs已更新。

I check the "Build action" of the Global.asax file which is set to "Content" and Copy always in the file properties. 我检查Global.asax文件的“构建操作”,该文件设置为“内容”,复制始终在文件属性中。

How to update global.asax together with global.asax.cs on publish command? 如何在publish命令中将global.asax与global.asax.cs一起更新?

Global.asax doesn't usually change. Global.asax通常不会改变。 Global.asax is compiled into a class deriving from the Global class in your Global.asax.cs . Global.asax被编译成一个派生自Global.asax.cs Global类的类。

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. 您只需将Global.asax复制到生产服务器,将Global.asax.cs编译为程序集。

See the MSDN : 请参阅MSDN

At run time, Global.asax is parsed and compiled into a dynamically generated .NET Framework class derived from the HttpApplication base class. 在运行时,Global.asax被解析并编译为从HttpApplication基类派生的动态生成的.NET Framework类。 The Global.asax file itself is configured so that any direct URL request for it is automatically rejected; 配置Global.asax文件本身,以便自动拒绝任何直接URL请求; external users cannot download or view the code written within it. 外部用户无法下载或查看其中编写的代码。

So as Patrick has already mentioned, there is no need to change it. 正如Patrick已经提到的那样,没有必要改变它。 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. 将更改保存到活动的Global.asax文件时,ASP.NET页面框架会检测到该文件已更改。 It completes all current requests for the application, sends the Application_OnEnd event to any listeners, and restarts the application domain. 它完成对应用程序的所有当前请求,将Application_OnEnd事件发送到任何侦听器,然后重新启动应用程序域。 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. 当来自浏览器的下一个传入请求到达时,ASP.NET页面框架将重新编译并重新编译Global.asax文件并引发Application_OnStart事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM