Two Different Programming Models
ASP.NET Web Pages follows a page-centric programming model reminiscent of classic ASP or PHP: a single .cshtml file mixes HTML markup, inline @{ } code blocks, and page logic together, and that one file is both what renders the response and what handles the form submitted back to it. ASP.NET MVC instead separates responsibilities across three kinds of files, a Controller class containing C# action methods, a Model representing the data being worked with, and a View (also often a .cshtml file) that focuses purely on rendering, with routing deciding which controller action handles an incoming URL before any view is even chosen.
Cricket analogy: A solo net-practice session where one player bowls, bats, and umpires their own session mirrors a Web Pages file handling markup, logic, and processing together, whereas MVC's separate captain, bowler, and umpire roles mirror Controller, Model, and View.
Routing and File Structure
Web Pages uses implicit, convention-based routing: a file named about.cshtml sitting in the site root is automatically reachable at /about, and a file inside a Products folder named Details.cshtml is reachable at /Products/Details, with no route table to configure. MVC instead defines routes explicitly, typically in RouteConfig.cs, mapping URL patterns like {controller}/{action}/{id} to a controller class and action method by convention, or mapping specific patterns to specific actions when the default pattern doesn't fit; this indirection means a URL in MVC does not need to correspond to any file on disk at all, only to a controller and action name.
Cricket analogy: A ground where every net corresponds directly to a numbered pitch, no scheduling office involved, mirrors Web Pages' implicit file-to-URL routing, whereas a tournament fixture list assigning matches to venues mirrors MVC's explicit RouteConfig.
Code Organization and Testability
Because Web Pages mixes markup and C# logic in the same .cshtml file, testing business logic in isolation typically means extracting it into a separate helper class first; the page itself is hard to unit test directly since it depends on the ASP.NET request pipeline to run. MVC's controllers are plain C# classes with action methods that take parameters and return results, so a unit test can instantiate a controller, call an action method directly, and assert on the returned ActionResult without spinning up a web server at all, which is a major reason larger teams favor MVC for applications with significant business logic.
Cricket analogy: Testing a batting technique against a bowling machine in a controlled net, without needing a full live match, mirrors MVC's ability to unit test a controller action directly without running a full web server.
When to Choose Which
Web Pages remains a reasonable choice for small sites, prototypes, and scenarios built originally in WebMatrix where a single developer owns the whole codebase and the page-per-file mental model maps naturally onto the site's structure, such as a small business brochure site with a contact form and a handful of content pages. MVC is generally the better fit once an application grows significant business logic, needs a team of developers working on different layers concurrently, or requires the kind of automated test coverage that depends on the separation MVC's Controller/Model/View split provides, and many real Web Pages sites are eventually migrated to MVC or a newer framework as they grow.
Cricket analogy: A casual weekend gully cricket match needing minimal organization mirrors a small Web Pages site, whereas an international Test match's full backroom staff mirrors an MVC application supporting a large development team.
// ASP.NET Web Pages: about.cshtml, reachable at /about by convention
@{
var title = "About Us";
}
<h1>@title</h1>
<p>We build small tools for local businesses.</p>
// ASP.NET MVC: HomeController.cs, route mapped via RouteConfig.cs
public class HomeController : Controller
{
public ActionResult About()
{
ViewBag.Title = "About Us";
return View();
}
}
// Views/Home/About.cshtml renders the markup separately
// Unit test against the controller directly, no web server needed
[TestMethod]
public void About_SetsExpectedTitle()
{
var controller = new HomeController();
var result = controller.About() as ViewResult;
Assert.AreEqual("About Us", controller.ViewBag.Title);
}Both Web Pages and classic MVC render Razor .cshtml files and can share the same WebSecurity, Validation, and Database helpers, so migrating a small Web Pages site into an MVC controller/view structure is usually incremental rather than a full rewrite.
- Web Pages mixes markup, logic, and form handling in one .cshtml file per URL.
- MVC separates responsibilities into Controllers, Models, and Views, with routing choosing the controller action first.
- Web Pages uses implicit, file-based routing; MVC uses an explicit route table, typically in RouteConfig.cs.
- MVC controller actions are unit-testable in isolation; Web Pages files depend on the request pipeline.
- Web Pages suits small sites, prototypes, and single-developer projects built originally in WebMatrix.
- MVC suits larger applications with significant business logic, team development, and automated test coverage needs.
- Both frameworks can share Razor syntax and helpers like WebSecurity, Validation, and Database.
Practice what you learned
1. How does ASP.NET Web Pages determine that a request for /about should render about.cshtml?
2. In ASP.NET MVC, what typically decides which code handles an incoming URL?
3. Why are MVC controller actions generally easier to unit test than a Web Pages .cshtml file?
4. Which scenario is generally the better fit for ASP.NET Web Pages rather than MVC?
5. What do Web Pages and MVC have in common?
Was this page helpful?
You May Also Like
Forms and Validation in Web Pages
Learn how ASP.NET Web Pages reads posted form data and enforces validation rules using the Validation helper, from server checks to optional client-side hints.
Database Access in Web Pages
Learn how the WebMatrix.Data.Database helper connects ASP.NET Web Pages to SQL databases with lightweight Query, Execute, and parameterized SQL methods.
Deploying Web Pages Sites
Understand how to publish an ASP.NET Web Pages site to production using FTP or Web Deploy, configure web.config for release, and set correct IIS and App_Data permissions.
Related Reading
Related Study Notes in Microsoft Technologies
Browse all study notesWindows 10 / UWP Development Study Notes
.NET · 30 topics
Microsoft TechnologiesWindows Batch Scripting Study Notes
Batch · 30 topics
Microsoft TechnologiesMFC (Microsoft Foundation Classes) Study Notes
C++ · 30 topics
Microsoft TechnologiesSilverlight Study Notes
.NET · 30 topics
Microsoft TechnologiesXAML Study Notes
.NET · 30 topics
Microsoft TechnologiesWPF (Windows Presentation Foundation) Study Notes
.NET · 30 topics