NHibernate, HttpModules, ASP.NET JSON Web Services and Database Transactions
March 18th, 2010
First of all sorry for the frankly appalling title which is actually longer than some of my posts. In order to explain let’s start with a problem definition. These are the elements that were in play:
- An ASP.NET 3.5 Web Forms based website (although #3 below is really the key factor )
- NHibernate
- The use of an HttpModule to implement the Open Session in View pattern and provide a Unit of Work implementation (one ISession per HTTP request)
- ASP.NET web services returning JSON (might well be a problem if the result was XML as well)
private bool IsAjaxError() { return HttpContext.Current.Response.StatusCode == 500 && HttpContext.Current.Request.RawUrl.Contains(".asmx"); }Obviously if an error is detected I can take the appropriate action. So if you’re using the above combination of technologies be careful because what you think is happening and what is happening might be two entirely different things.



Recent Comments