asp.net - NHibernate - how to handle user sessions -


I think what I'm doing here is a quick example of how to do it. It's okay to work properly with me, I can create new records with no problems, and do not read any problems in existing records. The problem I am facing is with the asp.net user session and how do I handle this fact in the middle of the load of that page, and I want to write it sometimes in the database.

  • In the user's logs
  • NHibernate brings user records
  • The user is stuffed in the record asp.net session.
  • The NHibernate session (I think) ends
  • The app displays a link to the "Add Address" page
  • The user visits the "Add Address" page < / Li>
  • The user enters the address address
  • The user clicks on "Deposit"
  • Add the address to the user object
  • User object to database
  • When I try to write back to user object (complete with new address), I get an error That the user object is already connected to an existing session. I am using the code below to exclude the user from asp.net sessions, add the address and return it back to the database. It is just at that point where it hits. When things go wrong, the know-how are completely connected.

      Zero AddAddress_Click (Object Sender, EventArgs E) {var session = Global.SessionFactory .GetCurrentSession (); User user = (user) HttpContext.Current.Session ["user"]; User.AddAddress (txtDescription.Text, txtLine1.Text, txtLine2.Text, txtTown.Text, txtCounty.Text, txtPostCode.Text, txtCountry.Text); Session.SaveOrUpdate (user); Session.Flush (); }  

    Please ignore the 101 ways for which maybe it is probably wrong, I know it well. I just want to do some work to prove myself that NHibernate is the road ahead for this project, so it will be a bit quicker and dirty in the moment.

    Post-text "itemprop =" text ">

    Using a normal practice single eSession per request is possible with the NHibernate, otherwise it may be called" Open session in view "or Is known as "OSI" and see.


    Comments

    Popular posts from this blog

    c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

    Calling GetGUIThreadInfo from Outlook VBA -

    Obfuscating Python code? -