Can I use ASP.NET's Session functionality

Discussion in 'ASP.NET / ASP.NET Core' started by Owen Ransen, Apr 18, 2014.

  1. Just as I was getting to grips with Sessions and session states I read this:

    "Server farm limitations. As users move from server to server in a Web server farm, their session state does not follow them. ASP session state is machine specific."

    Does this apply to DiscountASP servers? Or rather, can I reliably use code like this (look at the "Session"):

    Code:
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(Session["BackgroundColor"] != null)
            {
                // Get the data of the current session...
                ColorSelector.SelectedValue = Session["BackgroundColor"].ToString();
                BodyTag.Style["background-color"] = ColorSelector.SelectedValue;
            }
        }
    
     
  2. Oops. I read wrong:

    That quote was for ASP session states. ASP.NET session states don't apparently have those problems...
     
  3. mjp

    mjp

    Your account is on one server here, no "server farm." Under normal circumstances you'll stay on the same server until you have a reason or desire to move to another one.
     
    Owen Ransen likes this.
  4. FrankC

    FrankC DiscountASP.NET Staff

    I still suggest you use SQL session because it will persist the session even though the process gets recycle (eg. idle timeout).

    Open a support ticket, we'll create the session DB schema for you.
     
    Owen Ransen likes this.
  5. Ok, many thanks for the info.

    Aha, but that would mean I'd have to understand what I was doing ;)

    I'm still a 3 year old child as far as ASP.NET is concerned. I'll read up on what you've suggested... thanks for the reply.
     

Share This Page