473,772 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problems with WebService EnableSession in VS2005

Hi everybody,

I've got two questions about using the EnableSession property with an
ASP.NET WebService:

First Question:
I'm trying to create a web service with EnableSession=t rue.
I can't get it to work with VS2005 ( It works with vs2003!).

Here is my testcase:

I created two web services (hosted on IIS on the same computer).
One WebService was created using VS2005:

[WebMethod(Enabl eSession=true)]
public string GetSessionID()
{
return this.Context.Se ssion.SessionID ;
}

The other was created using VS2003:
[WebMethod(true)]
public string GetSessionID()
{
return this.Context.Se ssion.SessionID ;
}

Then I created a simple WinForms application (with 1 button and 1 listbox):

public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

// this is the web reference to the VS2005 web service.
localhost.Servi ce srv=new TestWebServiceS ession2.localho st.Service();
CookieContainer cookies=new CookieContainer ();
// this is the web reference to the VS2003 web service.
localhost1.Serv ice1 srv1=new
TestWebServiceS ession2.localho st1.Service1();
CookieContainer cookies1=new CookieContainer ();

private void button1_Click( object sender, EventArgs e )
{
srv.CookieConta iner=cookies;
string s=srv.GetSessio nID();
listBox1.Items. Add(s);

srv1.CookieCont ainer=cookies1;
s=srv1.GetSessi onID();
listBox1.Items. Add("*"+s);
}
}

When I click on the button the program calls both web services and adds the
session IDs returned to the listbox.
I can see that the VS2003 webservice returns the same session id everytime.
The VS2005 returns a different session ID.

I called the web services from IExplorer when Fiddler running and I see that
the VS2003 web service returns a cookie:
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Thu, 15 Feb 2007 08:34:14 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Set-Cookie: ASP.NET_Session Id=zbextf45fder t255admh01na; path=/
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 109

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">zbextf45fdert 255admh01na</string>
The VS2005 web service does NOT return a cookie:
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Thu, 15 Feb 2007 08:20:39 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 109

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">1l5ccq2mktsfv 0342j5hxa45</string>

Am I doing something wrong or is is a problem with ASP.NET 2.0?

Second Question:
The cookie that stores the session id is asp.net specific, right?
So if I need to write a web service (given a WSDL) to work with a certain
application (which I didn't write)
I can't make the web service session enabled because the application will
not send the cookie ?

Thanks,

Nadav
Feb 15 '07 #1
4 3265
Hello Nadav,

As for the SessionID problem you meet in ASP.NET webservice call, it is
likely due to the sessionID lazy initializing feature in ASP.NET. For
ASP.NET sessionstate module, it will always assign a random sessionID for
each page request(event of the same client) if you haven't stored any data
in the SessionState. This can avoid allocating unused server-side
sessionstate storage. This has also be mentioned in the ASP.NET session FAQ:

#Understanding session state modes + FAQ
http://forums.asp.net/7504/ShowPost.aspx

Here is the original description picked from the FAQ:
>>>>>>>>>>>>>>> >>>>>>>>>>>>> >
Q: Why does the SessionID changes in every request?
A: This may happen if your application has never stored anything in the
session state. In this case, a new session state (with a new ID) is
created in every request, but is never saved because it contains nothing.

However, there are two exceptions to this same session ID behavior:
- If the user has used the same browser instance to request another page
that uses the session state, you will get the same session ID every time.
For details, see "Why does the SessionID remain the same after the Session
times out?"
- If the Session_OnStart event is used, ASP.NET will save the session state
even when it is empty.
<<<<<<<<<<<<<<< <<<<<<<<<<<<< <<

therefore, for your scenario, your webservice may first store a small
placeholder data into session so as to make the sessionID fixed. You can
try testing it to see whether it works.

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.
Feb 16 '07 #2
Hi Steven,

I've tried it, and if I save something in the session then the session ID
remains the same.
So EnableSession=t rue DOES work with ASP.NET 2.0.
The thing I don't understand is that 'Understanding session state modes +
FAQ' page
last updated date is Sept 21, 2004.
So I would think that the page describes the behaiviour of asp.net 1.1.
However, in the VS2003 web service I got the session ID even if I didn't
save anything in the session.
Oh, Never mind. As long as it works with ASP.NET 2.0..
Thanks for your help.

Nadav

Feb 18 '07 #3
Thanks for your followup Nadav,

Yes, that FAQ article has been generaetd early at ASP.NET 1.x time. Most of
its implemenation feature and behavior applies for both ASP.NET 1.X and
2.0. For the session ID behvior, it does be consistent between ASP.NET 1.1
and 2.0 application(at least for webform application scenario). For the
webservice proxy of your VS 2003 webservice, I think there may already
exists some data in the server session or the ASP.NET 1.x webservice will
put some placeholder data whenever we enablesession for webservice. So far
I haven't got indepth on this.

Anyway, glad that you've got it working and if there is anything else we
can help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Feb 19 '07 #4
Hi Steven,

I've come up to this article when searching information on keeping a
webservice 'alive'.

Let's say that we would use a webservice (ASP.NET 2.0 / IIS 5) for
authentication (using soapheaders) and then make further use of other methods
within the same webservice to expose data from our back-end system (where our
ERP/... is running) to our customers.

Would this be a good approach ? And do you know if we could use the session
for keeping the state of the currently authenticated user ?

Thanks for a reply.

Sincerely

Ivo

"Steven Cheng[MSFT]" wrote:
Thanks for your followup Nadav,

Yes, that FAQ article has been generaetd early at ASP.NET 1.x time. Most of
its implemenation feature and behavior applies for both ASP.NET 1.X and
2.0. For the session ID behvior, it does be consistent between ASP.NET 1.1
and 2.0 application(at least for webform application scenario). For the
webservice proxy of your VS 2003 webservice, I think there may already
exists some data in the server session or the ASP.NET 1.x webservice will
put some placeholder data whenever we enablesession for webservice. So far
I haven't got indepth on this.

Anyway, glad that you've got it working and if there is anything else we
can help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights
Mar 2 '07 #5

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

Similar topics

0
1059
by: jhcorey | last post by:
I'm having some difficulty trying to figure out how to do this. The help topics seem to be still referring to VS2003 In VS2003 (1) I get the webservice reference. (2) I add using myProject._myWebService; At this point _myWebService pops up in intellisense in VS2003, not in VS2005.
0
1232
by: frankgerlach | last post by:
When trying to run the sample web services of the mono distribution (file /opt/mono-1.1.10/lib/xsp/test/1.1/webservice/TestService.asmx), I get the following error message in my web browser: Compilation Error Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error. Error message: (0,0) : error CS0006: Cannot find assembly `System.Data' (0,0) : error CS0006:...
1
3239
by: Thorsten | last post by:
Hi, I try to use the WebService from MS CRM 3.0 but I always get a Time-out. So I make a really simple testapp which uses the following code: --------- CrmService.CrmService service = new CrmService.CrmService(); service.Url = crmserviceurl; service.Credentials = System.Net.CredentialCache.DefaultCredentials;
1
3732
by: Stefano Magni | last post by:
Hi all, Is it possible debug my WebService that I've published under IIS WebServer ? The default permit to debug only in ASP.NET Develepment WebServer. Thanks Stefano
2
1052
by: Michael E Baltic | last post by:
VS 2005 allows for web sites and services to be run without installing IIS. What if I want to create a SOA application for a non-internet connected environment? For example: I have a pc running a local, lightweight database. I want my pocket pc to be able to synch and run live off of the pc by interacting with a web service. Let's just say that I can't install IIS. Plus, this allows me to develop the same product for places that...
0
1914
by: rob | last post by:
I am trying to debug a webservice by steping into a web method called from a windows form project. The strange thing is that sometimes it works but often it does not. When it does not work I get the following error when trying to step into a web method: Unable to automatically step into the server. The remote procedure could not be debugged. This usually indicaes that debugging has not been enabled on the server. See help for...
4
4623
by: Bit Byte | last post by:
I'm having problem compiling one of my projects with VS2005. The problems arise with VS2005 (apparent?) inability to compile log4cpp. Has anyone succesfully compiled log4cpp using VS2005? Here are the errors I get: Error 1 error C2039: 'iterator_category' : is not a member of 'log4cplus::helpers::string_append_iterator<_Container>' c:\program files\microsoft visual studio 8\vc\include\xutility 572
0
1147
by: Vids | last post by:
Hi, We are doing migration of web service from VS2003 to VS2005 After upgrading the project I m trying to add a web reference to the web service. While adding web reference it shows all the web methods inside that web service but it show the message in the right "There was an error downloading 'http://localhost/MyWebSite/WebServices/Journal.asmx'. The request failed with the error message: -- <html><head><title>Object...
2
1058
by: xpnctoc | last post by:
Hello, Does anyone know anything about problems with running VS2005 / VS2005B2 side-by-side? When I installed 2008B2, it seemed to break a number of things in 2005. Consider: I have an extensive 2005 C++/CLI project. Is used to build with 0 errors and 0 warnings. On the weekend I installed VS2008B2, I went back to 2005 and tried to rebuild my project. BOOM! 351 WARNINGS! First thing I did was check to make sure I was opening the project in...
0
9621
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
9454
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
10264
Oralloy
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...
0
9914
tracyyun
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...
0
8937
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
6716
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
5355
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
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.