Session in WebService with ASP.NET - Please Help

J

Juan Irigoyen

I have a page asp that call the webmethod, this make the variable of session
but when the webmethod return the values stored
in webmethod lost.

In the web.config have the next code

<sessionState mode="InProc" cookieless="false" timeout="20"></sessionState>


[WebMethod(EnableSession = true)]
public int GestionTicket Inicio()
{
Session.Add("SesionNivel", 1);
Session.Add("SesionTipo", "a");
Session.Add("SesionAccesos", 0);
return 1;
}
 
J

Joe Mayo [C# MVP]

Hi Juan,

Try instantiating the CookieContainer on your client proxy:

proxy.CookieContainer = new System.Net.CookieContainer();

Joe
--
Joe Mayo, Author/Instructor
Need C#/.NET training?
visit www.mayosoftware.com
C# Tutorial - www.csharp-station.com



Juan Irigoyen said:
I have a page asp that call the webmethod, this make the variable of session
but when the webmethod return the values stored
in webmethod lost.

In the web.config have the next code

<sessionState mode="InProc" cookieless="false"
timeout="20"> said:
[WebMethod(EnableSession = true)]
public int GestionTicket Inicio()
{
Session.Add("SesionNivel", 1);
Session.Add("SesionTipo", "a");
Session.Add("SesionAccesos", 0);
return 1;
}
 
M

Mike Newton

The session for your web application and the session for your web
service are not the same. When you make a call to a web service, and it
places something in session, the calling page will never know what that is.

You should create a structure for the return data, something like:

struct GestionData{
public int nivel;
public string tipo;
public int sesionaccessos;
}

and set those values, then return the structure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top