Session Variables, Web Services, ASP.NET, and C#
<p>I'm having an issue with ASP.NET's session variables and a web service proxy object. I can access any data I create inside the actual .asmx file, but adding data "Through" the session variable results in absolutely nothing happening.</p>

<p>My goal is quite simple, I want to create an "Almost Shopping cart". The customer enters a title into this text box, and it's sent to the Web Service. The web service is called in the masterpage, and it grabs an array list full of the "titles" that the customer is requesting.</p>

<p>The data is visible in a drop down box, and a label that stores the total cost of all the items (I'm not worried about the cost at the moment).</p>

<p>The issue is, anytime I call a web service method, absolutely nothing happens.</p>

<p>The Code in question:</p>

<p><b>Basket.asmx</b></p>

<pre><code>public class basket  : System.Web.Services.WebService {

ArrayList reservations = new ArrayList();
double total = 0;

public basket()
{
    reservations.Add("Extreme Test Data");
    reservations.Add("Moar Test Data");
}

[WebMethod]
public string[] getReservations()
{
    //This may be part of the issue, still not sure.

    return (string[])reservations.ToArray(typeof( string));
}
[WebMethod]
public string toString()
{
    return reservations[reservations.Count - 1].ToString();
}


[WebMethod]
public double getTotal()
{
    return total;
}

[WebMethod]
public void addCost(double price)
{
    total = total + price;
}

[WebMethod]

public void addReservation(String title)
{

    reservations.Add(title);

}
[WebMethod]
public void removeReservation(string title)
{
}
[WebMethod]
public int getLength()
{
    return reservations.Count;
}
</code></pre>

<p><b>Global.asax</b></p>

<pre><code>    void Session_Start(object sender, EventArgs e) 
{
    // Code that runs when a new session is started
    localhost.basket proxy = new localhost.basket();
    Session["reservations"] = proxy;
}
</code></pre>

<p>(Everything else in global.asax is default)</p>

<p><b>Masterpage</b></p>

<p>This is the only relevant code in the masterpage, It calls the web service through the session variable.</p>

<pre><code>    protected void Page_Load(object sender, EventArgs e)
{

    localhost.basket proxy = (localhost.basket)Session["reservations"];

        lblTotal.Text = proxy.getTotal().ToString("c");
        string[] res = proxy.getReservations();
        ddReservations.DataSource = res;
        ddReservations.DataBind();
        proxy.addReservation("Half Life 2");
}
</code></pre>

<p><b>Reservations.aspx</b></p>

<p>This page submits the actual "new" data to the web service. I've cut out a lot of this (It's a group project, so there's a lot of code I didn't write).</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    proxy = (localhost.basket)Session["reservations"];
    Response.Write(proxy.toString() + "Count: " + proxy.getLength());

}

  protected void cmdSubmit_Click(object sender, EventArgs e)
{
    proxy.addReservation(txtGameTitle.Text);        
    proxy.addCost(39.99);
}
</code></pre>

<p>What does work: The default test values I entered in the ASMX, they load fine into the textbox.</p>

<p>So in short, can I use a web service proxy object in a session variable? If not, whats the best way to "share" this object?</p>

<p>Also: I'm using VS2005.</p>

<p>Thanks for any help!</p>
