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

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Why Banners module will stop rotating bannersWhy Banners module will stop rotating banners
Previous
 
Next
New Post
12/31/2008 10:04 AM
 

To begin this issue is version specific and has been addressed in 4.9.0 but there is still a bug in 4.9.1 which I will explain later.

The Problem

Assuming you have the banners module setup correctly and it should be rotating, as perhaps it does on your local machine. Then the issue the banners not rotating has to do with your servers performance not directly the configuration / programming of the banners module.

The details of the problem are:

DNN caches the last viewed banner's ID in RAM by way of the ASP.NET System.Web.Caching.Cache function. In the BannerController.vb it will then look to grab the last ID out of cache. If the cache is empty (more on this later) then it return a NOTHING object.


Here is where the version specific issue comes into play. Prior to version 4.9.0 if the cache object returned NOTHING then it would start with index of 0 for the banner rotation (meaning the same banner would show up every time).


Now for the reason why the ASP.NET cache object would return NOTHING?


I'm not 100% sure of the percentages but the problem is the Physical memory usage and Application Pool memory usage. If the Physical memory is within 10% of using all physical memory (bring up taskmgr and look at the memory. if it's over the amount of ram you actually have then you'll see this problem). ASP.NET will reject cache requests and begin garbage collection (deleting) what is currently in the cache. This will also happen if your application pool is within 20% of its own limit (If one is set).


In version 4.9.0 a randomize function was added when the cache object returned NOTHING. However a slight programming logic prevents it from including the last index for a banner in the randomizing so if you have 3 banners only 1 and 2 will show up.


NOTE: Because the banners module writes directly to ASP.NET's cache system. Changing the Cache Performance settings in Host Settings will not have anything to do with this.

Fixing the problem:
1.    Upgrade to 4.9.1 and get a mostly working rotator
2.    Wait for DNN to fix the fail over randomizer
3.    Modify the function manually

To fix the problem download the latest source of DNN 4.9.1
Under Library > Components > Vendor > BannerController.vb grab two functions (LoadBanners and IsBannerActive)
Add those two functions to Website > Admin > Vendors > DisplayBanners.vb

Find:
lstBanners.DataSource = objBanners.LoadBanners(intPortalId, ModuleId, intBannerTypeId, strBannerGroup, intBanners)
and replace with:
lstBanners.DataSource = LoadBanners(intPortalId, ModuleId, intBannerTypeId, strBannerGroup, intBanners)

Then if you want to fix the randomize issue

Find:
intLastBannerIndex = RandomGenerator.Next(0, arrBanners.Count -1)
Replace with:
intLastBannerIndex = RandomGenerator.Next(0, arrBanners.Count)


Sr. Software Engineer
 
New Post
12/31/2008 1:31 PM
 

jsheely wrote

Find:
intLastBannerIndex = RandomGenerator.Next(0, arrBanners.Count -1)
Replace with:
intLastBannerIndex = RandomGenerator.Next(0, arrBanners.Count)

I don't agree with this fix. 

The collection is 0 - based.  If the Count is 3 (as in your example), the Random Generator will return 0, 1 or 2, which is correct, for a 0-based collection of 3 items.  Your fix would return 3 which exceeds the bouds of the collection. 

The code won't break, as there is logic further down which resets the index to 0 if > Count-1, but it would not be correct.


Charles Nurse
Chief Architect
Evoq Content Team Lead,
DNN Corp.

Want to contribute to the Platform project? - See here
MVP (ASP.NET) and
ASPInsiders Member
View my profile on LinkedIn
 
New Post
12/31/2008 1:33 PM
 

With regard to your explanation of why the cache expires, you are correct, although in my experience the "scavenging" occurs at a much lower %.

The ASP.NET Cache is scavenged before other memory, and in my experience occurs when ~50-60% of physical RAM is being used.


Charles Nurse
Chief Architect
Evoq Content Team Lead,
DNN Corp.

Want to contribute to the Platform project? - See here
MVP (ASP.NET) and
ASPInsiders Member
View my profile on LinkedIn
 
New Post
12/31/2008 8:38 PM
 

Charles,

 

I thought the same thing for the array length. I didn't really dig in to determine why it works I just know that with the arrsBanner.Count-1 set and an array collection containing 3 items it will only display the first two. I hit refresh around 100 times to confirm it but I never ran it through debug to see why.

I'll review it again to see what happens.

Jon

 


Sr. Software Engineer
 
New Post
1/1/2009 3:27 PM
 

Okay back from testing.

The fix should definetly work. The Random.Next function second paramater of maxValue is the number of possibilities which is also 0 based. So an array of 3 items would return array.count=3 which is 0,1,2 and the random.next(0,3) has three possibilities, again 0,1,2

I wrote a quick console app to make sure. Running this indexId will never return a 3.

 Random randomize = new Random();
            int indexId;
            int i=0;

            do
            {
                indexId = randomize.Next(0, 3);
                System.Console.Write(indexId + ",");
                i++;

            } while (i < 800);
            Console.ReadKey(true);


Sr. Software Engineer
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Why Banners module will stop rotating bannersWhy Banners module will stop rotating banners


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