the common term is session per request. if you google this you will
come up with a lot of information on managing units of work in the web
environment. With NH ISession is a unit of work.  Most documentation I
have seen on session per view assumed an MVC framework. if you are
using webforms some of the details on managing transactions will
change the concept of beginning a session when the request starts and
completing the session when the request ends will remain the same.

as Jason Denter recommends: avoid scoping the session, or entities
beyond the request, it's more trouble than it's worth.

On Aug 4, 3:38 am, Patric Forsgard <[email protected]> wrote:
> Hi Jason,
>
> Thanks for your reply. Do you know if it exists some best practice how I
> should use NHibernate in an web-environment?
>
> // Patric
>
> On 4 August 2010 02:07, Jason Dentler <[email protected]> wrote:
>
> > Hi Patric,
>
> > Welcome to NHibernate.
>
> > I strongly suggest all beginners avoid overriding major NHibernate
> > internals, as suggested in that blog post.
>
> > Lazy load exceptions are a symptom of architectural issues in your
> > application. Use session per request and store the entity id in the url,
> > view data or session so it survives a round trip. Don't hang on to the
> > session or entity itself from one web request to the next.
>
> > I assume you are using ASP.NET webforms. Even with Burrows, it's best to
> > avoid spanning sessions across requests when possible. You should use
> > Burrows for the WebForms extras, not the long conversation feature.
>
> > Thanks,
> > Jason
>
> > On Tue, Aug 3, 2010 at 3:42 PM, Patric Forsgard <[email protected]>wrote:
>
> >> Hi all.
>
> >> For the first, i'm new on NHibernate and try to get the best out of
> >> the product when I building asp.net web-application.
>
> >> Now over to my problem. When I post objects between pages I offen get
> >> LazyInitializationException that say that the session not is connected
> >> when try to get childobjects that is marked for lazy-loading. To get
> >> ride of this problem i google a lot and find an article that helps me
> >> get ride of the problem.
>
> >>http://dobbydotnet.blogspot.com/2010/03/no-more-nhibernate-lazyinitia...
>
> >> Now I have to hear with all you guys that have working with NHibernate
> >> what your fealing is to solve the problem on the way in the article or
> >> if I should use traditional one and span the session (like
> >> NHibernate.Burrow does) between the requests.
>
> >> Best regards Patric
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "nhusers" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected]<nhusers%[email protected]>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/nhusers?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to