473,722 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3603
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.Http Context.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.New Guid().ToString ();
}

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

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

[WebMethod]
public string GetMyStuff(stri ng token)
{
//get the user string identified by the token//
return (string) System.Web.Http Context.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
Jerbil_X
1 New Member
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
1656
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 id is embedded in the url. In the trace log I find that the session id is sometimes empty, I assume this happens when server 2 is handling the requst, instead of the server where the session was created. Does anybody have any clue
3
2016
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, JSP, ASP) is one of the of the following: - user's IP, but ambiguous - using cookies, sometimes disregarded due to possibility of turning off in a browser; no need to control flow of data, checking links - controlling every link, the uses can...
3
1853
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 6 and NS 7. NS behaves as expected: it has no recall of previous requests. With IE however my app works as normal: I can still store and retrieve values from session state. Am I imagining this? If not it suggests to me that IE 6 always includes a...
1
2315
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 Exception is handled by the client exception policy...basically it logs the information coming from the business layer... We then create a custom message object that contains user/context specific information and adds that to the Session object.....
9
5311
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 copy paste (I hear this will improve in ASP.Net 2 via master pages). When I navigate from one page to the next the header and footer user controls lose their state because they are effectively different instances of the user control. Is there...
4
2201
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. The web farm is doing searches which are quite performance expensive against the ldap server, taking up to 10 or 15 seconds. The searches are displayed to the client in a datagrid, which then may have to be paged.
1
2075
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 using State session mgt. In this case i want to know if we use Application variable then where
18
3441
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 File-New-Window creates an instance of IE in the same process with the same SessionID as the parent window is in big trouble. This fundamentally restricts the usefullness of using session state management. I probably missed it somewhere - can...
2
5009
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 web.config 3. Yes, I tried IE - Tools - Privacy - Accept All Cookies and also Override automatic cookie handling, Always allow session cookes
2
1195
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, Membership methods are called to obtain the ID, that value is stored in the session state, and that value is then returned. This appears to work fine. However, I'm now giving users of one type the ability to "impersonate" another. In this case,...
0
8867
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8740
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9239
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9158
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8059
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5996
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4764
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3208
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.