Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesJust one Module Initialized for all browser requests?Just one Module Initialized for all browser requests?
Previous
 
Next
New Post
1/13/2012 6:20 PM
 

When multiple browsers access the same page with the same module, is there only one instance of the Module class initialized for all the browser requests or each request has its own "application pool"?

When I was debugging one application with a variable defined as:

public partial class View : MyModuleModuleBase, IActionable    

{

public static int myInt=someFce(differentArg); //fce returning different return values for differentArg

all browsers displayed the same value of myInt (the one that was first assigned with the first run of the module.

Thx for an insight on this as it really puzzled me and started me worrying about the scope of classes..etc.

 
New Post
1/14/2012 8:48 PM
 
This is expected behaviour as you've declared you myInt as a static (shared in vb.net) type - this means it operates effectively as a global variable (unlike non-static properties where each class instance is unique) - see http://www.blackwasp.co.uk/CSharpStaticBehaviour.aspx for more background on static's behaviour.

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
1/15/2012 7:02 PM
 

Thx, I'll check out that link, though I don't think I have a problem understanding static variables in general. 

I don't know, I really thought that each browser request would always recreate everything from scratch and that the application "remembers only" thanks to sessions, viewstates..etc. and not that a request from browser B could read values that were set by browser A that had opened that module before browser B did which is what happnes here. 

How long then stays the instance of the module class alive?

So, that brings me to my previous question...what is the lifecycle of a module under DNN. Lets say you upload your module and a browser opens a page with that module. Static variables are set when the first browser requested that module. But then, how long will these variables be available for requests from different computers...?

Thx a lot for your time. Have a good day.


 
New Post
1/16/2012 2:24 AM
 

Thx for you reply. I think I don't have such a problem understanding static variables. The thing that surpised me the most was the following behaviour and my current understanding of browser requests and how you can pass values among them.

Up until now, I thought that the state of web application was maintained via "sessions/viewstate" and that each request starts with a clean sheet and only later on it's values are recovered from "sessions".

But here, the fact that values initialized when broswer A requested a module are available to requests from other browsers suggests, that the module class stays alive on the server with its static variables setup from the first visit and that subsequent requests from different browsers on different computers accessing the module can read/write to these variables. In fact, I find it extemely handy.

I'll have to simulate a situation when two requests come at the same time though, because I don't know if in that case the value would stay the same for one browser...or if and that will be the case, I think, It can changed during the life cycle of its response.

The question is when is it freed from memory all together?

If interested, I willsend you the visual studio project sample file so that you see what I mean.

Thx again for your reply.


 
New Post
1/16/2012 7:28 AM
 
DotNetNuke uses caching where approriate (e.g. for pages, users etc.) and expires these caches when data is changed. Module developers can also use caching -and this can be set easily via the dnn manifest file so it is possible that is your issue -check the definition of the relevant module control under host->extensions to see if this is what your seeing

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesJust one Module Initialized for all browser requests?Just one Module Initialized for all browser requests?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out