我试图找出这个问题的答案,但找不到清晰的答案。所以我的问题是,在我粘贴的代码中:
此代码在.NET 2.0 2.0服务中执行。
[WebMethod]
[SoapHeader ("Credentials", Required=true)]
public void DoSomething ()
{
if (AuthenticationModule.IsValid (Credentials) && AuthenticationModule.CanPerformAction (Credentials, Permissions.DoSomething)) {
using (ISession session = NHibernateUtil.SessionFactory.OpenSession()) {
if(Condition)
throw new ApplicationException("Super exception");
session.Close ();
}
}
else
throw new SecurityException("Invalid user or inssuficient privileges");
}发布于 2013-08-14 19:30:54
是的,using语句确保为给定对象调用Dispose(),请参见其文档。
HTTPApplication在其类文档中记录事件顺序。即使面对未处理的异常,也会执行EndRequest事件。
https://stackoverflow.com/questions/18239766
复制相似问题