473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Session state handling

Hi guys,
I'm making a webservice that will be used by a pocketpc app. I want to be
able to keep an instance of some things (there are 2 collections and possibly
a database connection).

Is there a way to keep the state of the server? So that these collections
are not lost between method calls?
Nov 23 '05 #1
2 3585
Hi,

Since webservices are essentially statless you would need to pass a token
indentifying the user with every method call and using the Session object on
the webservice side. In normal windows applications this can be done by
setting CookieContainer property on the webservice proxy.

This unfortunatly is not supported in the .net compact framework as far as
I know so you cant use the session and you have to do things manually to
maintain state as follows:

1- Provide a method to generate a token id for the user.
2-Pass the id with every method call to the web service.
3-On the webservice side you can store the client data by using
the asp .net cache - System.Web.HttpContext.Current.Cache (warning this
cache isn't replicated so it won't work if you have a webfarm)

//just a quick code snippet webservice side//
//i'm storing a user string you could store any other object//

[WebMethod]
public string GetMyToken()
{
//just returning a unique id to identify the user usually this would be
done after authentication//
return System.Guid.NewGuid().ToString();
}

[WebMethod]
public void SaveMyStuff(string stuff,string token)
{

//save the user string in the asp.net cache//
System.Web.HttpContext.Current.Cache[token]=stuff;
}

[WebMethod]
public string GetMyStuff(string token)
{
//get the user string identified by the token//
return (string) System.Web.HttpContext.Current.Cache[token];
} code snippet webservice side//
Regards,

Rami Farhat

"Riga" wrote:
Hi guys,
I'm making a webservice that will be used by a pocketpc app. I want to be
able to keep an instance of some things (there are 2 collections and possibly
a database connection).

Is there a way to keep the state of the server? So that these collections
are not lost between method calls?

Nov 23 '05 #2
thank you! your solution was very usefull, if there is anything that i can help you with, count on me!! :)
Jul 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nikander Bruggeman | last post by:
Hi, In a situation where I have 2 servers which are load balanced I keep losing session state, although I store the session state in sql server and use a cookieless session, so that the session...
3
by: news.onet.pl | last post by:
Hello I'm biting into the following problem: HTTP is stateless protocol and thus net languages' designer had to find out session. As far as I know session handling in any of the language (PHP,...
3
by: Richard P | last post by:
I am experiencing some browser weirdness. My app uses session state to hide values I prefer to keep out of the querystring. I am testing to see what happens when cookies are fully disabled in IE...
1
by: Oscar Thornell | last post by:
Hi, I have an ASP.NET page that generates an Exception... The Exception is not caught in the executing method...so it propagates to..the Page_Error event handling method.. In that method the...
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
4
by: John Allberg | last post by:
Hi! We have a problem which is correlated to web farms and session handling and are thinking of what solution to choose. Our setup is with a web farm, one ldap server and a database cluster. ...
1
by: ankushmn | last post by:
i am working on web application in Asp.Net, C# in which we are using Outproc session mgt. As we manage session using Outproc there are two ways 1) Sql Server 2) State Server in above we are...
18
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
2
by: StanB | last post by:
I came across this weird problem: 1. Session state stops working after the app is deployed to another server because IE does not accept cookies. 2. It works if cookieless="true" in the...
2
by: Jonathan Wood | last post by:
I have a static class member that returns the ID of the current user. When it is called, it checks if the value is already stored in the session state, if it is, that value is returned. Otherwise,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.