using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

using System.Net;           // needed for the CookieContainer

 

namespace WebServices

{

    public partial class WebServiceSessionExample1 : System.Web.UI.Page

    {

        VoteSvc.VoteService pxy;

 

        protected void Page_Load(object sender, EventArgs e)

        {

            // Check to see if the web service proxy object was created and savd in the Session object

            if (Session["pxy"] == null)

            {

                pxy = new VoteSvc.VoteService();

                pxy.CookieContainer = new CookieContainer();

                Session["pxy"] = pxy;

            }

            else

            {

                pxy = (VoteSvc.VoteService)Session["pxy"];

            }

        }

 

        protected void btnVote_Click(object sender, EventArgs e)

        {

            int count = 0;

 

            pxy.AddVote();

            count = pxy.GetVoteCount();

 

            lblDisplay.Text = "You voted " + count + " times.";

        }

 

        protected void btnViewResults_Click(object sender, EventArgs e)

        {

            Response.Redirect("WebServiceSessionExample1_Results.aspx");

        }

    }

}