473,884 Members | 2,319 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session access in web service locks the multithreading

I have a problem - if I access the session in Web Service, as soon as I
anything in it, requests are no longer running in parallel - instead,
they are
queued and executed sequentially. Here is an example (ASP.NET 2.0, VS

Web service method (web service is a regular asmx):

[WebMethod(Enabl eSession = true)]
public String DoNothing()
Thread.Sleep(10 000);
// HttpContext.Cur rent.Session["initvar"] = 123;
return HttpContext.Cur rent.Session.Se ssionID;

Client (console application with web reference):

class Program
static void Main(string[] args)
Program pr1 = new Program();
Program pr2 = new Program();
System.Net.Cook ieContainer cc = new
System.Net.Cook ieContainer();
localhost.CellS earchService svc1 = new
localhost.CellS earchService();
svc1.CookieCont ainer = cc;
Console.WriteLi ne(svc1.DoNothi ng());
localhost.CellS earchService svc2 = new
localhost.CellS earchService();
svc2.CookieCont ainer = cc;
svc1.DoNothingC ompleted += new
WebSvcTester.lo calhost.DoNothi ngCompletedEven tHandler(pr1.sv c_DoNothingComp leted);
svc2.DoNothingC ompleted += new
WebSvcTester.lo calhost.DoNothi ngCompletedEven tHandler(pr2.sv c_DoNothingComp leted);
svc1.DoNothingA sync();
svc2.DoNothingA sync();
Console.In.Read Line();

void svc_DoNothingCo mpleted(object sender,
WebSvcTester.lo calhost.DoNothi ngCompletedEven tArgs e)
Console.WriteLi ne(e.Result);

See that first call is sync, and next 2 are async. If in web service
method I have this line commented out:

// HttpContext.Cur rent.Session["initvar"] = 123;

then async calls are processed in parallel, and for all 3 calls I get
different session ids. But if I uncomment it, async calls are executed
sequentially, and all 3 session ids are the same.

Looks like as soon as something is stored in a session (thus, session
is actually used), something in .NET framework prevents requests from
multithreading. Can I make it not so intelligent and leave this
decision to me? I will take care of threads synchronization myself.

Jul 12 '06 #1
0 1136

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

Similar topics

by: Billy Jacobs | last post by:
I am having a problem with my session variable being set to Null for no apparent reason. I am declaring it like the following when the user logs in. dim objUserInfo as new clsUserInfo 'Set some properties objUserInfo.UserName = txtUserName.text.trim objUserInfo...
by: ehendrikd | last post by:
hi all i need some clarification on how the php session work in relation to cookies. we have a web site where users need to log in. a few of our users were having troubles with their browser clients having different levels of cookie security settings. i assumed a solution would be to have the php site use the session only, and set session.use_cookies to 0 in the php.ini file. after doing this, the session no longer persits after
by: Clint | last post by:
Hey all - Excuse the cross-post ... I'm not sure what the appropriate newsgroup would be for this question. I have a question that I'm not quite sure how to ask. For all I know, I have the verbaige completely wrong, but here goes nothing ... I'm currently using the MS Data Access Block for a desktop application I'm writing. Recently, I had to add a call to a web service, which in
by: Ilia | last post by:
Hi folks, I have some problems with ASP.NET Session State. The following simple program runs well if the Session State set as "InProc". If I switch to "SQLServer", the changes, made by the second thread, are lost. Any idea? I use VS.NET 2003 on Windows Server 2003 with hot fixes (as of 30-Oct-2003) and SQL Server 2000 SP 3a.
by: Mark | last post by:
Ok, I know that .net inherently does not share session data across asp.net projects, but is there any decent work around to this. We already have a big chunk of our application using the asp.net session object (using state service). I'd like to start breaking out our functionality into component projects, but I'd like to get this session issue worked out first. Any ideas?? I found this article , but it sounds like kind of a pain.
by: Thomas Nielsen [AM Production A/S] | last post by:
Hi, I have one web form (WebForm1.aspx) from which i would like to display the output of another web form, WebForm2.aspx, in a controlled environment. I do this by using HttpWebRequest to request WebForm2 from the WebForm1 code-behind, and this works flawlessly. I would also like to be able to share the Session objects between the two webforms. I'm trying to do this by passing the ASP.NET_SessionId cookie on WebForm1 to WebForm2. This...
by: kingski | last post by:
I have a web site created with ASP.NET 1.1. availability Global.asax: protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
by: Glenn | last post by:
Hi I've been experimenting with managing state using the Session object. I've created a simple WS with a couple of methods, one which sets a string value, another that retrieves it. Each method has the WebMethodAttribute.EnableSession set to true. When I run the test page the session is maintained. However, using a console application, in between setting the string value and attempting to
by: Djblurr | last post by:
Hi guys, I've been stuck on this problem for days now at work and its driving me insane. Basically there is a system in place at multiple locations that is an open source project running with ms access. This system holds customer records and order data, and its written in asp. We have a web service that sits at each of these locations written in vb.net and it is called by our system, on one of our servers. The web service is used online,...
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...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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();...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.