|
The session management mode in the config file of ASP.NET is "inproc"
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Hi Thomas
I had exactly the same problem starting with web stuff a short while back and I was like WTF??*&^*&*%%&^(*& are my objects?
The answer is short and sweet. In ASP.NET objects are stateless, meaning the will be recreated with every pageview.
Now the fix, and I'm not really sure if this the correct way, but all u need to do is mark those two variables in question as static. They will now retain their state.
Hope this helps
|
|
|
|
|
leppie wrote:
Now the fix, and I'm not really sure if this the correct way, but all u need to do is mark those two variables in question as static.
I tried this once and could not get it to work.
I just wanted to test it out so I built a webservice that incrimented a variable by one each time it was hit.
The variable was always zero.
|
|
|
|
|
Ray Cassick wrote:
I just wanted to test it out so I built a webservice that incrimented a variable by one each time it was hit.
Are you sure it was hit hard enough, maybe a 10 pound hammer will better
Ray Cassick wrote:
The variable was always zero.
That was the problem i had, before the object was marked static. Well it solved my problem...well, I wouldnt say it looks right, but it was my first try.
CHeers
|
|
|
|
|
I found the answer:
On the line that says [WebService]
change to
[WebService(EnableSession=true)]
and it works!!!!
modified 29-Aug-18 21:01pm.
|
|
|
|
|
WOW thanx, I need all the tips I can get
I think in my case static was the right answer, as the variable needed to have application scope and was started in the application started event and shutdown in the application end event.
It seems to work but with many problems. Normal builds didnt update the assembly on the webserver, so I have to do a Re-build every time. Not sure if this is normal
Cheers
|
|
|
|
|
Now the second part of my problem remains.
The web application starts a new session every time a web method on the WebService is called, even though I have created an instance of the Web Service in the Session_Start and kept it in a Session Variable.
Very unfortunate
Any ideas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Thomas George wrote:
The web application starts a new session every time a web method on the WebService is called, even though I have created an instance of the Web Service in the Session_Start and kept it in a Session Variable.
SOmething sounds funny. Remember any session variables will only be there for the duration of the session. Maybe the session gets reset somewhere . Try adding breakpoints at session start/end events and see what happens....
Good luck
|
|
|
|
|
i got the answer for this one too.
After creating the WebService object, create a cookie container for it.
Suppose you web service name is xyz.ws
so the code in Session_Start will be
xyz.ws ws1 = new xyz.ws();
ws1.CookieContainer = new System.Net.CookieContainer;
Session["ws1"] = ws1;
Now you can get the same WebService session from this Web App Session using the session variable.
Nice talking to you though. Got me thinking on a lot of things. I work here alone and I need someone to talk to about tech stuff once in a while .
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Thanx Thomas
Very helpful indeed.
O BTW , I spotted this website and downloaded it, but forgot about it ... DOPE!
http://samples.gotdotnet.com/quickstart/aspplus/doc/default.aspx[^]
When I was looking at it, it looked very helpful indeed, much better than the "few" examples on MSDN.
Thomas George wrote:
Nice talking to you though. Got me thinking on a lot of things. I work here alone and I need someone to talk to about tech stuff once in a while .
Thanx again I work from home, but prefer to work alone, with some online help. Unfortunately my free GPRS connection comes to an end this month, so daytime will be a bit lonely untill ADSL becomes available in my area (local peak phone calls are probably the highest in the world (i dont even want to mention the cost per MB for GPRS once this free trial ends )).
Cheers
|
|
|
|
|
The code in the previous post is for the web application. Web service objects created in an app by default is sessionless ie, it does not store the cookies. We just create a cookie container and ,wow, it is like invoking from a browser...
modified 29-Aug-18 21:01pm.
|
|
|
|
|
So the only difference between a web app and a web service is how a session is defined?
|
|
|
|
|
When a web application becomes the client for a webservice, that has state, the web application should identify the session in every request to the web service. Normally, this does not happen because the Web application does not store cookies. But, the Web service proxy object inside the web application can store the cookie, if one is created by the user.
The web service by default does not manage states - because it is a performance overhead. So, we have to explicitly enable session support for each web method that needs it, so that the session is loaded for the particular web method call (an extra load which we ask the ASP.NET framework to do by the EnableSession=true directive).
modified 29-Aug-18 21:01pm.
|
|
|
|
|
If I make it static, will the static variable have app scope or session scope?
I wonder whether the value will be seen by all objects of the class, irrespective of the ownership
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Thomas George wrote:
If I make it static, will the static variable have app scope or session scope?
I wonder whether the value will be seen by all objects of the class, irrespective of the ownership
I declared my object as public static in the Global class and I could use it from anywhere. Now this is why I think it's not a good idea, security wise.
|
|
|
|
|
I have seen talk on google about setting the sessionState parm in web.config = "StateServer"
Would that help?
IMHO Stateful web services is kind of an oxymoron that opens up a large can of worms.
Can't you store your state in the registry or DB?
|
|
|
|
|
I found the answer:
On the line that says [WebService]
change to
[WebService(EnableSession=true)]
and it works!!!!
modified 29-Aug-18 21:01pm.
|
|
|
|
|
MS implemented tabs in VS .NET, a feature they ignored
in previous versions (good, old CBuilder . But did they
forgot to add a build-incrementing function again?
(like the one in the good, old CBuilder)
(well in C# and .NET it could be something different but
I cannot figure it out in the C++ version at all - the
"classic one, the unmanaged one")
All the free add-in for VS 6.0, I tried, didn't work.
BTW I haven't seen the good, old CBuilder for years but I
feel that VS .NET reminds me very much the good, old
CBuilder.
|
|
|
|
|
Zinj wrote:
But did they
forgot to add a build-incrementing function again?
Nope, well not in C#. Just go to Project Properties, Configuration properties, Advanced, set incremental build to true. Now, goto AssemblyInfo.cs and make sure the following looks like this:
[assembly: AssemblyVersion("1.0.*")]
Now the part with the "*" will auto increment.
NOTE: This is on by default for debug builds and off for release builds.
Hope this helps
|
|
|
|
|
does sombody knows why myDateTime.AddMinutes doesn't do anything?
i am trying to do:
DateTime myDateTime = Convert.ToDateTime("18/09/2002 13:00");
myDateTime.AddMinutes(40);
but nothing happen to this myDateTime??
thanks in advance, sharon
|
|
|
|
|
sharon wrote:
DateTime myDateTime = Convert.ToDateTime("18/09/2002 13:00");
myDateTime.AddMinutes(40);
Try myDateTime = myDateTime.AddMinutes(40)
The Add... methods only return another DateTime, they don't modify the object. This is pretty much common across the .NET Framework.
Paul
|
|
|
|
|
thank you very much, it was very helpfull, sharon
|
|
|
|
|
Hi !
I'd like to know how can I pass parameters to an ActiveX in a c# windows application. As far as I know, the ActiveX control implements IPersistPropertyBag so that the container in html can pass the params through the Tag PARAM in the HTML tag OBJECT. However, I don't know how to do it within a c# application.
Please, somebody could help me ???
thx in advance,
|
|
|
|
|
Derive AxHost, you've got the following protected load methods :
DepersistControl();
DepersistFromIPropertyBag(IPropertyBag propBag);
DepersistFromIStorage(IStorage storage);
DepersistFromIStream(IStream istream);
DepersistFromIStreamInit(IStream istream);
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
Sorry but I'm quite new in c# and I don't know exactly what u mean, could u please explain it?
When I add my Ax control "myCtrl" in the aplication, I think Aximp.exe creates AxmyCtrl which is the wrapper for my control and is dervied from AxHost.
However, if I derive this class, I can't find the protected methods u talked about. I've looked in the help for the members of AxHost and I don't find those protected methods.
Could u tell me more exactly what should I do?
thx for everything,
ORi.
|
|
|
|