Chapter 57: ASP AdRotator Component

ASP AdRotator Component.

This is the exact lesson that appears in the W3Schools Classic ASP tutorial, and it was one of the most exciting things for beginners in 1998–2005 because it let you show rotating banner ads on your website with almost no coding.

I will explain it like your favorite teacher who actually used AdRotator on real client sites back in the early 2000s (when banner ads were the main way small websites made money) — slowly, clearly, with real working examples, good habits, common mistakes, security notes, and the exact patterns you would see in legacy Indian small-business, portal, and community sites that still run this way in 2026.

1. What is the AdRotator Component?

AdRotator is a built-in ActiveX Server Component that comes with IIS and Classic ASP.

Its only job is to:

  • Read a simple text file (usually called ads.txt or adrotator.txt) that lists banner ads
  • Pick one ad randomly (or weighted) each time the page loads
  • Automatically generate the correct <a href=”…”><img src=”…”></a> HTML tag
  • Rotate ads fairly over time (keeps track of impressions internally)

It was extremely popular because:

  • Banner advertising was the main monetization model in the late 90s / early 2000s
  • You didn’t need JavaScript or external ad networks
  • It worked perfectly with Classic ASP pages
  • Very easy to set up and manage (just edit a text file)

Even in 2026, some very old Indian classifieds portals, community sites, and internal company portals still use AdRotator for simple internal banner rotation or legacy ad deals.

2. How AdRotator Works — The Three Main Pieces

You need three things to use AdRotator:

  1. The AdRotator component itself (already installed on IIS)
  2. A schedule file (text file with ad list — usually called ads.txt)
  3. The <object> tag on your .asp page to place the rotating ad

Step 1: The Schedule File (ads.txt) — The Heart of AdRotator

This is a plain text file (usually in the root or /ads folder). Format is very strict — every 4 lines = one ad entry.

Example ads.txt:

text

Line-by-line explanation:

  1. REDIRECT redirect.asp — optional — if present, all clicks go through this page (for tracking)
  2. WIDTH 468 — banner width (global for all ads)
  3. HEIGHT 60 — banner height
  4. BORDER 0 — border thickness (usually 0)
  5. * — separator between global settings and first ad
  6. Image URL
  7. Click-through URL (where user goes when clicking)
  8. Width (per ad — can override global)
  9. Height
  10. Alternate text (tooltip)
  11. Weight / priority (higher = more often shown)

→ Total weight = 10 + 30 + 20 = 60 → Ad 1 shown ~17% of time, Ad 2 ~50%, Ad 3 ~33%

3. Step 2: Place AdRotator on Your Page

asp

Key points:

  • The <object> tag is required — this is how you instantiate the COM component
  • ad.GetAdvertisement(path) — tells it which ads.txt file to read
  • TargetFrame=”_blank” — opens ad link in new tab (optional)

4. Step 3: The Redirect Page (for Tracking Clicks — Very Common)

File: redirect.asp

asp

→ All ad clicks go through redirect.asp?url=… → you can log impressions/clicks before redirecting.

5. Security & Best Practice Warnings (Critical in 2026)

  • Never let users control the schedule file path — hard-code Server.MapPath(“ads/ads.txt”)
  • Never allow write access to the ads.txt folder — classic ASP sites were hacked via file upload + overwriting ad files
  • Use Server.HTMLEncode if you ever display ad info from the file
  • Disable FSO write access to web folders — many hacks used FSO + AdRotator folders
  • Log clicks/redirects — otherwise you cannot track ad performance
  • In 2026 legacy code → still used for internal banners or old ad deals, but very risky without strict permissions

6. Teacher Summary – ASP AdRotator Component in Classic ASP

ASP AdRotator is:

  • A built-in COM component (clsid:…) that rotates banner ads
  • Reads a simple text schedule file (ads.txt) with ad list + weights
  • Automatically generates <a><img> HTML
  • Supports REDIRECT page for click tracking
  • Global settings: WIDTH, HEIGHT, BORDER
  • Per-ad settings: image URL, click URL, alternate text, weight
  • Used with <object runat=”server” classid=”…”> + ad.GetAdvertisement(path)
  • Very popular 1998–2005 for banner ads on small sites
  • Still alive in many legacy Indian portals, community sites, and internal dashboards

This is how millions of Classic ASP sites showed rotating banners and earned ad revenue in the early 2000s — and many legacy systems still use exactly this AdRotator pattern in 2026.

Next class?

  • Want a full example with click logging + database tracking?
  • Or how to weight ads differently and test rotation?
  • Or compare Classic ASP AdRotator vs modern banner rotation (Google Ad Manager, etc.)?
  • Or move to the next W3Schools topic (ASP Content Linking or ASP Content Rotator)?

Just tell me — I’m here! 🚀🇮🇳 Keep learning strong, Webliance! 😊

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *