惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
Jina AI
Jina AI
博客园_首页
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
Forbes - Security
Forbes - Security
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
N
News | PayPal Newsroom
S
Security Archives - TechRepublic
量子位
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
C
Cisco Blogs
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
Scott Helme
Scott Helme
S
Securelist
Security Latest
Security Latest
爱范儿
爱范儿
TaoSecurity Blog
TaoSecurity Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
Intezer
L
LINUX DO - 最新话题
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Check Point Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
美团技术团队
Know Your Adversary
Know Your Adversary
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
PCI Perspectives
PCI Perspectives
月光博客
月光博客
T
Tailwind CSS Blog
Cloudbric
Cloudbric
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
K
Kaspersky official blog
D
DataBreaches.Net
博客园 - 【当耐特】
有赞技术团队
有赞技术团队

博客园 - zhanqiangz(闲云野鹤)

在ReportService2005.asmx 找不到 ReportingService2005 类 BizTalk相关的问题,打算持续更新。 恢复被格式化过的硬盘数据 BizTalk - Most possible reason for “is Delimiters are not unique” in EDI transaction What happens if BizTalk artifacts are not GACed? XmlSerializer is not trustable BizTalk - How to create custom functoid. BizTalk - Carefully use Send Port Group BizTalk - How to debug map in VS2005 BizTalk-Get to know functoid. BizTalk - String Functoids 一辈子都忘不了的七夕节 Head First Design patterns笔记-Singleton patterns (从“一夫一妻制社会中婚约的达成”看单件模式) 使用HttpApplication实例(翻译) Head First Design patterns笔记-Decorator Patterns (从”用不同技能武装自己”看装饰模式) Head First Design patterns笔记-Observer Patterns (从TFS的Project alerts功能看观察者模式) ASP.NET 2.0的编译行为 Head First Design patterns笔记-Strategy Patterns (从不同的人使用不同的交通工具上班看策略模式) 晕菜了,TFS居然把vss里的那个rollback功能cut掉了,还好有人写了工具.
Global.asax文件里的Application_Init能触发吗?
zhanqiangz(闲云野鹤) · 2007-06-07 · via 博客园 - zhanqiangz(闲云野鹤)

在项目中遇到一个bug,结果发现是因为把一些在整个web应用程序启动时应该执行的代码放到了Application_Init中,但是这个方法在web应用程序启动的过程中并没有触发.我用的环境是VSTS,不管是web site项目还是web application项目都是这样,也委托我的朋友在VS2003里做了验证,结果一样不能触发.你可以白度或者Google一下,关于Application_Init的文章很多,大多都说在web应用程序启动的时候触发,并且在整个生命周期只执行一次.下面的文章来源于网络:

Global.asax 文件,有时候叫做 ASP.NET 应用程序文件,提供了一种在一个中心位置响应应用程序级或模块级事件的方法。你可以使用这个文件实现应用程序安全性以及其它一些任务。
    Global.asax
文件被配置为任何(通过 URL 的)直接 HTTP 请求都被自动拒绝,所以用户不能下载或查看其内容。ASP.NET 页面框架能够自动识别出对Global.asax 文件所做的任何更改。在 Global.asax 被更改后ASP.NET 页面框架会重新启动应用程序,包括关闭所有的浏览器会话,去除所有状态信息,并重新启动应用程序域。


Global.asax
文件继承自HttpApplication 类,它维护一个HttpApplication 对象池,并在需要时将对象池中的对象分配给应用程序。Global.asax 文件包含以下事件:

·         Application_Init:在应用程序被实例化或第一次被调用时,该事件被触发。对于所有的HttpApplication 对象实例,它都会被调用。

·         Application_Disposed:在应用程序被销毁之前触发。这是清除以前所用资源的理想位置。

·         Application_Error:当应用程序中遇到一个未处理的异常时,该事件被触发。

·         Application_Start:在HttpApplication 类的第一个实例被创建时,该事件被触发。它允许你创建可以由所有HttpApplication 实例访问的对象。

·         Application_End:在HttpApplication 类的最后一个实例被销毁时,该事件被触发。在一个应用程序的生命周期内它只被触发一次。

·         Application_BeginRequest:在接收到一个应用程序请求时触发。对于一个请求来说,它是第一个被触发的事件,请求一般是用户输入的一个页面请求(URL)。

·         Application_EndRequest:针对应用程序请求的最后一个事件。

·         Application_PreRequestHandlerExecute:在 ASP.NET 页面框架开始执行诸如页面或 Web 服务之类的事件处理程序之前,该事件被触发。

·         Application_PostRequestHandlerExecute:在 ASP.NET 页面框架结束执行一个事件处理程序时,该事件被触发。

·         Applcation_PreSendRequestHeaders:在 ASP.NET 页面框架发送 HTTP 头给请求客户(浏览器)时,该事件被触发。

·         Application_PreSendContent:在 ASP.NET 页面框架发送内容给请求客户(浏览器)时,该事件被触发。

·         Application_AcquireRequestState:在 ASP.NET 页面框架得到与当前请求相关的当前状态(Session 状态)时,该事件被触发。

·         Application_ReleaseRequestState:在 ASP.NET 页面框架执行完所有的事件处理程序时,该事件被触发。这将导致所有的状态模块保存它们当前的状态数据。

·         Application_ResolveRequestCache:在 ASP.NET 页面框架完成一个授权请求时,该事件被触发。它允许缓存模块从缓存中为请求提供服务,从而绕过事件处理程序的执行。

·         Application_UpdateRequestCache:在 ASP.NET 页面框架完成事件处理程序的执行时,该事件被触发,从而使缓存模块存储响应数据,以供响应后续的请求时使用。

·         Application_AuthenticateRequest:在安全模块建立起当前用户的有效的身份时,该事件被触发。在这个时候,用户的凭据将会被验证。

·         Application_AuthorizeRequest:当安全模块确认一个用户可以访问资源之后,该事件被触发。

·         Session_Start:在一个新用户访问应用程序 Web 站点时,该事件被触发。

·         Session_End:在一个用户的会话超时、结束或他们离开应用程序 Web 站点时,该事件被触发。

使用这些事件的一个关键问题是知道它们被触发的顺序。Application_Init Application_Start 事件在应用程序第一次启动时被触发一次。相似地,Application_Disposed Application_End 事件在应用程序终止时被触发一次。此外,基于会话的事件(Session_Start Session_End)只在用户进入和离开站点时被使用。其余的事件则处理应用程序请求,这些事件被触发的顺序是:

·         Application_BeginRequest

·         Application_AuthenticateRequest

·         Application_AuthorizeRequest

·         Application_ResolveRequestCache

·         Application_AcquireRequestState

·         Application_PreRequestHandlerExecute

·         Application_PreSendRequestHeaders

·         Application_PreSendRequestContent

·         <<执行代码>>

·         Application_PostRequestHandlerExecute

·         Application_ReleaseRequestState

·         Application_UpdateRequestCache

·         Application_EndRequest

这些事件常被用于安全性方面。下面这个 C# 的例子演示了不同的Global.asax 事件,该例使用Application_Authenticate 事件来完成通过 cookie 的基于表单(form)的身份验证。此外,Application_Start 事件填充一个应用程序变量,而Session_Start 填充一个会话变量。Application_Error 事件显示一个简单的消息用以说明发生的错误。

protected void Application_Start(Object sender, EventArgs e) {
Application["Title"] = "Builder.com Sample";
}
protected void Session_Start(Object sender, EventArgs e) {
Session["startValue"] = 0;
}
protected void Application_AuthenticateRequest(Object sender, EventArgs e) {
// Extract the forms authentication cookie
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if(null == authCookie) {
// There is no authentication cookie.
return;
}
FormsAuthenticationTicket authTicket = null;
try {
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
} catch(Exception ex) {
// Log exception details (omitted for simplicity)
return;
}
if (null == authTicket) {
// Cookie failed to decrypt.
return;
}
// When the ticket was created, the UserData property was assigned
// a pipe delimited string of role names.
string[2] roles
roles[0] = "One"
roles[1] = "Two"
// Create an Identity object
FormsIdentity id = new FormsIdentity( authTicket );
// This principal will flow throughout the request.
GenericPrincipal principal = new GenericPrincipal(id, roles);
// Attach the new principal object to the current HttpContext object
Context.User = principal;
}
protected void Application_Error(Object sender, EventArgs e) {
Response.Write("Error encountered.");
}

网络上的资料大多是msdn文档的转载或者翻译,并且提供的例子里都没有对Application_Init的描述.
大家有对这个东东有经验的吗?欢迎在我的博客中留下你的见解.谢谢!