P
Per Loevgren
I want to set and get information in a Session variable on an IIS
application (ASP.NET website) from a Windows App.
I use webservices to communicate with the IIS app. and keep all calls
from the webservices in the same session.
I have deployed my webservices to the folder where the IIS app resides
and when I call to get the value of an Application variabel there are
no problems, but as soon as I call to get the value of a Session
variable I get an exception.
If i call the webservice from my ASP.NET app. there are no problems
with the session variable.
The Webservice looks as follows:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
namespace StatusWS
{
public class GetStatus : System.Web.Services.WebService
{
public GetStatus()
{
//CODEGEN: This call is required by the ASP.NET Web Services
Designer
InitializeComponent();
}
#region Component Designer generated code
//Required by the Web Services Designer
private IContainer components = null;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
[WebMethod (EnableSession=true)]
public string GetStatusApplication( string strSerialNo, string OTP )
{
string strStatus = Application["Status"] != null ?
Application["Status"].ToString() : "<No status found>";
return Server.HtmlEncode(strStatus);
}
[WebMethod (EnableSession=true)]
public string GetStatusSession( string strSerialNo, string OTP )
{
string strStatus = Session["Status"] != null ?
Session["Status"].ToString() : "<No status found>";
return Server.HtmlEncode(strStatus);
}
}
}
I have deployed it by copying the asmx file to the ASP.NET application
folder, and added a webreference to it in my windows app.
The windows app. calls like this:
private void button1_Click(object sender, System.EventArgs e)
{
textBox1.Text = new StatusWS.GetStatus().GetStatusSession( "", "" );
}
private void button2_Click(object sender, System.EventArgs e)
{
textBox2.Text = new StatusWS.GetStatus().GetStatusApplication( "", ""
);
}
I have tried to set CookieContainer on my webservice object but that
didn't do any good.
Any ideas or thoughts are most welcome
Rgds.,
Per Loevgren
application (ASP.NET website) from a Windows App.
I use webservices to communicate with the IIS app. and keep all calls
from the webservices in the same session.
I have deployed my webservices to the folder where the IIS app resides
and when I call to get the value of an Application variabel there are
no problems, but as soon as I call to get the value of a Session
variable I get an exception.
If i call the webservice from my ASP.NET app. there are no problems
with the session variable.
The Webservice looks as follows:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
namespace StatusWS
{
public class GetStatus : System.Web.Services.WebService
{
public GetStatus()
{
//CODEGEN: This call is required by the ASP.NET Web Services
Designer
InitializeComponent();
}
#region Component Designer generated code
//Required by the Web Services Designer
private IContainer components = null;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
[WebMethod (EnableSession=true)]
public string GetStatusApplication( string strSerialNo, string OTP )
{
string strStatus = Application["Status"] != null ?
Application["Status"].ToString() : "<No status found>";
return Server.HtmlEncode(strStatus);
}
[WebMethod (EnableSession=true)]
public string GetStatusSession( string strSerialNo, string OTP )
{
string strStatus = Session["Status"] != null ?
Session["Status"].ToString() : "<No status found>";
return Server.HtmlEncode(strStatus);
}
}
}
I have deployed it by copying the asmx file to the ASP.NET application
folder, and added a webreference to it in my windows app.
The windows app. calls like this:
private void button1_Click(object sender, System.EventArgs e)
{
textBox1.Text = new StatusWS.GetStatus().GetStatusSession( "", "" );
}
private void button2_Click(object sender, System.EventArgs e)
{
textBox2.Text = new StatusWS.GetStatus().GetStatusApplication( "", ""
);
}
I have tried to set CookieContainer on my webservice object but that
didn't do any good.
Any ideas or thoughts are most welcome
Rgds.,
Per Loevgren