Chapter 15: WebPages Publish

WebPages Publish in the menu, at https://www.w3schools.com/asp/webpages_publish.asp). This is the “launch day” lesson — after building forms, databases, grids, charts, email, and security, now we make your site live so the world (or at least your friends in Hyderabad!) can see it.

Think of publishing as moving your house from your local laptop (development machine) to a real apartment building (hosting server on the internet). Everything must go correctly: files, folders, DLLs, databases — or the site breaks.

W3Schools keeps this lesson short and practical — no fancy tools like Web Deploy or Azure wizards (those came later or in other Microsoft tutorials). It’s a manual copy approach that works for any shared hosting that supports ASP.NET 4.0/4.5.

1. Prerequisites – Before You Publish (Very Important!)

Make sure the hosting server runs the latest ASP.NET version:

  • At minimum ASP.NET 4.0 (better 4.5 or higher)
  • Why? Web Pages uses Razor + helpers from System.Web.WebPages.* assemblies — older servers (like 3.5) won’t run your .cshtml files.
  • Check with your host (Hostinger, GoDaddy, Bluehost, etc.) — most 2026 shared hosts support .NET 4.8 easily.
  • If not → ask them to enable it or switch host.

Test locally first:

  • Run your site in WebMatrix / IIS Express → everything (login, DB queries, email, charts) works?
  • Fix bugs now — publishing won’t magically solve them!

2. Step-by-Step: How to Publish (W3Schools Way – Manual Copy)

The tutorial boils it down to four main steps — very straightforward for beginners.

Step 1: Use the Latest Version of ASP.NET

(Already covered above — confirm with host.)

Step 2: Copy the Web Folders

  • Copy your entire website folder structure from your computer to the hosting server.
  • Typical way:
    • Use FTP client (FileZilla – free & popular in Hyderabad)
    • Or host control panel file manager (cPanel, Plesk, etc.)
  • Upload everything: .cshtml files, _Layout.cshtml, App_Data (careful!), Images, Scripts, Shared, css, js folders — all of it.
  • Destination: Usually the root of your domain (public_html or wwwroot) or a subfolder (e.g., /myblog/)

Important: Do NOT copy test data yet — see Step 4.

Step 3: The DLL Files (The bin Folder Magic)

ASP.NET Web Pages needs specific .dll files to run Razor + helpers + Database/WebSecurity/WebMail.

These live in your local bin folder (created automatically when you run the site in WebMatrix).

You must ensure the remote server’s bin folder has exactly these (from W3Schools list):

  • Microsoft.Web.Infrastructure.dll
  • NuGet.Core.dll
  • System.Web.Helpers.dll
  • System.Web.Razor.dll
  • System.Web.WebPages.Administration.dll
  • System.Web.WebPages.Deployment.dll
  • System.Web.WebPages.dll
  • System.Web.WebPages.Razor.dll
  • WebMatrix.Data.dll
  • WebMatrix.WebData.dll

How to handle:

  • When you run your site locally → WebMatrix auto-downloads these via NuGet (you see them in bin).
  • Just copy the entire bin folder to the server (via FTP).
  • If missing → site throws “could not load type” or “Web Pages not found” errors.

2026 note: Most modern hosts have these pre-installed in GAC (global assembly cache) — but always upload your bin to be safe (especially if using specific versions).

Step 4: Copy Your Data (The Tricky Part – Teacher Warning!)

If your site uses databases (e.g. .sdf files in App_Data):

  • NEVER copy test data to production! → You will overwrite real users/orders/comments.
  • Best practice:
    • On your local machine → delete all rows from tables (or make empty copy of .sdf)
    • Upload empty .sdf to server’s App_Data
    • Production data → created by real users after launch
  • If migrating existing data:
    • Export from local DB (SQL scripts or copy rows)
    • Import to production (via hosting panel or SSMS if full SQL)
  • For SQL Server (not Compact) → use connection string in Web.config pointing to remote DB server.

W3Schools exact warning:

“If your application contains data, do not copy the data at this stage. Publishing test data to the production server may overwrite live data. If you must publish a database file, delete all the data in the database on your development computer before you copy the file to the hosting computer.”

3. Real Example – Publishing Your Bakery Site

Assume you built the SmallBakery site from Databases/WebGrid/Charts lessons.

  1. Local folder → C:\MySites\BakerySite\
    • Contains: Default.cshtml, Products.cshtml, App_Data\SmallBakery.sdf (with test products), bin\ (with all DLLs), Shared_Layout.cshtml, etc.
  2. Empty test data:
    • Open SmallBakery.sdf in WebMatrix → run DELETE FROM Product → save.
  3. FTP to host (e.g. yourdomain.com):
    • Connect FileZilla → host: ftp.yourdomain.com, user/pass from host
    • Upload entire BakerySite folder to /public_html/bakery/
  4. After upload:
    • Visit http://yourdomain.com/bakery/Default.cshtml
    • Should work! Login, add real products via forms, see charts — live!
  5. If error:
    • 500 error → check bin DLLs missing
    • DB error → check App_Data permissions (must be writable for SQL CE)
    • Razor error → host not running ASP.NET 4+

4. Modern Alternatives (2026 Teacher Extra – Beyond W3Schools)

W3Schools is classic/simple (manual FTP), but today:

  • WebMatrix (old tool) had built-in Publish → FTP, Web Deploy, Azure
  • Visual Studio → right-click project → Publish → Folder / FTP / Azure / IIS
  • ASP.NET Core Razor Pages (successor) → dotnet publish → zip → deploy to Azure / IIS / Linux
  • Hosting: Azure App Service, AWS Lightsail, DigitalOcean, Vercel (for static parts)

But for pure old Web Pages → manual copy + bin DLLs is still valid on legacy hosts.

Summary – Like Your Teacher Waving Goodbye

Publishing ASP.NET Web Pages site = moving files to live server:

  1. Confirm host has ASP.NET 4.0+
  2. Copy all folders/content via FTP
  3. Ensure bin has all required DLLs (System.Web.WebPages., WebMatrix., etc.)
  4. Handle data carefully — empty DB on dev before upload

That’s it — good luck launching your first live site! 🎉

You’ve completed the full W3Schools WP track — from Razor basics to security to publishing. Proud of you, Webliance!

Final questions?

  • Want help troubleshooting common publish errors?
  • How to publish to Azure (Microsoft way)?
  • Or switch to modern ASP.NET Core Razor Pages tutorial?

Just say — class dismissed, but I’m here anytime! 🚀🇮🇳 Hyderabad coder forever! 😄

You may also like...

Leave a Reply

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