什么是asp.net的Global.asax的目的 [英] What is the purpose of global.asax in asp.net

查看:231
本文介绍了什么是asp.net的Global.asax的目的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何使用的Global.asax在asp.net?并且那是什么?

how can we use global.asax in asp.net? and what is that?

推荐答案

MSDN有Global.asax文件的目的大纲

实际上,Global.asax中,您可以编写响应运行code为系统级的事件,如应用出发,一个对话结束,应用程序错误发生的历史,而不必试图鞋拔即code到每一个和你的网站的每个网页。

Effectively, global.asax allows you to write code that runs in response to "system level" events, such as the application starting, a session ending, an application error occuring, without having to try and shoe-horn that code into each and every page of your site.

您可以通过在Visual Studio中选择Add>新建项目>全局应用程序类使用它。

You can use it by by choosing Add > New Item > Global Application Class in Visual Studio. Once you've added the file, you can add code under any of the events that are listed (and created by default, at least in Visual Studio 2008):


  • 的Application_Start

  • Application_End

  • 在session_start

  • Session_End中

  • 的Application_BeginRequest

  • Application_AuthenticateRequest

  • 的Application_Error

有其他活动,您还可以挂接到,比如LogRequest。

There are other events that you can also hook into, such as "LogRequest".

这篇关于什么是asp.net的Global.asax的目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆