Global文件的作用
2016-03-17 21:40
411 查看
该文件必须放在网站的根目录下。
public class Global : System.Web.HttpApplication // 以下代码是关于Global文件的执行,第一个方法,是找到Global文件,并且编译成一个类型 //_theApplicationFactory.EnsureInited(); // _theApplicationFactory.EnsureAppStartCalled(context);//确保Global文件中Application_Start方法被执行而且只执行一次。 { // 整个WEB应用程序的入口。相当于Main函数.该方法只执行一次,当WEB应用程序第一次启动时,执行该方法,后续请求其它页面该方法不在执行。该方法中一般完成对整个网站的初始化。 protected void Application_Start(object sender, EventArgs e) { } // 开启会话的时候执行该方法 protected void Session_Start(object sender, EventArgs e) { //统计访问人数. //访问人数+1. } protected void Application_BeginRequest(object sender, EventArgs e) { } // context.AcquireRequestState 也可以在这里写这个方法 用来代替HttpModuleHelper类实现Session 过滤 protected void Application_AuthenticateRequest(object sender, EventArgs e) { } // 注意的方法。该方法会捕获程序中没有处理的异常。并且将捕获的异常信息写到日志中。 protected void Application_Error(object sender, EventArgs e) { HttpContext.Current.Server.GetLastError();//捕获异常信息. } // 会话结束的时候执行该方法。 protected void Session_End(object sender, EventArgs e) { } // 整个应用程序结束的时候执行。 protected void Application_End(object sender, EventArgs e) { } }
相关文章推荐
- 访问Access数据库实现DropDownList二级异步联动(ASP.NET WebForm开发方式)
- 【笔记】HttpHandler与HttpMoudle
- repeater中CheckBoxList/RadioButtonList取值赋值
- asponse.word按模板导出word文档
- Asp.Net alert弹出提示信息的5种方法
- 当微软牛津计划遇到微信APP---一
- 7 天玩转 ASP.NET MVC — 第 2 天
- ASP.NET MVC 路由系统
- ASP.NET MVC 数据验证
- ASP.NET MVC Controller和Action
- ASP.NET MVC Filters
- ASP.NET MVC Razor视图引擎
- ASP.NET MVC Section
- ASP.NET MVC Partial View 和 Child Action
- ASP.NET MVC Helper Method
- ASP.NET MVC Model Binding
- asp.net mvc 解决漏洞扫描的Error messages on page
- 关于asp.net网址出现乱码问题的解决方法
- Response.WriteFile()文件流输出与迅雷冲突的解决办法
- 表单对应model生成