[Mono-bugs] [Bug 61762][Wis] New - WebService, SessionState and CookieContainer.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 20 Jul 2004 10:18:47 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by beniniva@csr.unibo.it.

http://bugzilla.ximian.com/show_bug.cgi?id=61762

--- shadow/61762	2004-07-20 10:18:46.000000000 -0400
+++ shadow/61762.tmp.12543	2004-07-20 10:18:47.000000000 -0400
@@ -0,0 +1,148 @@
+Bug#: 61762
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: RedHat FedoraCore2
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Sys.Web.Services
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: beniniva@csr.unibo.it               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: WebService, SessionState and CookieContainer.
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+
+Description of Problem:
+Service1.asmx.cs is a WebService example with only one method
+(SessionHitCounter) that increase a counter.
+----------------------------------------
+Service1.asmx.cs
+----------------------------------------
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Web;
+using System.Web.Services;
+
+namespace Contatore
+{	
+	public class Service1 : System.Web.Services.WebService
+	{
+		public Service1()
+		{
+		InitializeComponent();
+		}
+		#region Component Designer generated code
+		private IContainer components = null;
+		private void InitializeComponent()
+		{
+		}
+		protected override void Dispose( bool disposing )
+		{
+			if(disposing && components != null)
+			{
+				components.Dispose();
+			}
+			base.Dispose(disposing);		
+		}
+		#endregion
+		[ WebMethod(Description="Per session Hit Counter",EnableSession=true)]
+		public int SessionHitCounter() 
+		{
+			if (Session["HitCounter"] == null) 
+			{
+				Session["HitCounter"] = 1;
+			}
+			else 
+			{
+				Session["HitCounter"] = ((int) Session["HitCounter"]) + 1;
+			}
+			return ((int) Session["HitCounter"]);
+		}   
+	}
+}
+#####
+WebForm1.aspx.cs is a client web application that invoke
+"SessionHitCounter" method when click on the button.
+----------------------------------------
+WebForm1.aspx.cs
+----------------------------------------
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Web;
+using System.Web.SessionState;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.HtmlControls;
+using System.Net;
+
+namespace CounterCLI
+{
+	public class WebForm1 : System.Web.UI.Page
+	{
+		protected System.Web.UI.WebControls.Label Label1;
+		protected System.Web.UI.WebControls.Button Button1;
+		private ServerUsage.Service1 su = new ServerUsage.Service1();
+		private CookieContainer cookieJar;
+		private void Page_Load(object sender, System.EventArgs e)
+		{
+			
+		}
+		#region Web Form Designer generated code
+		override protected void OnInit(EventArgs e)
+		{
+			InitializeComponent();
+			base.OnInit(e);
+		}
+		private void InitializeComponent()
+		{    
+			this.Button1.Click += new System.EventHandler(this.Button1_Click);
+			this.Load += new System.EventHandler(this.Page_Load);
+		}
+		#endregion
+		private void Button1_Click(object sender, System.EventArgs e)
+		{				
+			// Check to see if the cookies have already been saved for this session.
+			if (Session["CookieJar"] == null) 
+				cookieJar= new CookieContainer();
+			else
+				cookieJar = (CookieContainer) Session["CookieJar"];
+			// Assign the CookieContainer to the proxy class.
+			su.CookieContainer = cookieJar;
+
+			// Invoke an XML Web service method that uses session state and thus
+cookies.
+			int count = su.SessionHitCounter();         
+
+			// Store the cookies received in the session state for future retrieval
+by this session.
+			Session["CookieJar"] = cookieJar;
+
+			// Populate the text box with the results from the call to the XML Web
+service method.
+			Label1.Text = count.ToString();  
+		
+		}
+	}
+}
+----------
+
+Actual Results:
+When I run WebForm1.aspx and I click the button the counter not increases
+of one unit to every call, but it remains always 1.
+
+Expected Results:
+Clicking on button of WebForm1.aspx the counter would have to increase of
+one unit to every call.