--- uid: web-pages/overview/releases/top-features-in-web-pages-2 title: "The Top Features in ASP.NET Web Pages 2 | Microsoft Docs" author: microsoft description: "This topic provides an overview of the top new features in the ASP.NET Web Pages 2, a lightweight web programming framework that is included with the WebMatr..." ms.author: aspnetcontent ms.date: 02/13/2012 ms.assetid: cc712e72-c3d0-4e43-bc2d-28cc09cd8f71 msc.legacyurl: /web-pages/overview/releases/top-features-in-web-pages-2 msc.type: authoredcontent --- The Top Features in ASP.NET Web Pages 2 ==================== by [Microsoft](https://github.com/microsoft) > This article provides an overview of the top new features in the ASP.NET Web Pages 2 RC, a lightweight web programming framework that is included with [Microsoft WebMatrix 2 RC](https://www.microsoft.com/web/). > > **What's included:** > > - [Installing WebMatrix](#install) > - [New and enhanced features](#New_and_Enhanced_Features) > > - [Changes for the RC release](#Changes_for_the_RC_Version) > - [Changes for the Beta release](#Changes_for_the_Beta_Version) > - [Using the New and Updated Site Templates](#templates) > - [Validating User Input](#validation) > - [Enabling logins from Facebook and other sites using OAuth and OpenID](#oauthsetup) > - [Adding Maps using the Maps Helper](#maphelper) > - [Running Web Pages Applications Side by Side](#sidebyside) > - [Rendering Pages for Mobile Devices](#mobile) > - [Additional Resources](#resources) > > > [!NOTE] > > This topic assumes that you are using WebMatrix to work with your ASP.NET Web Pages 2 code. However, as with Web Pages 1, you can also create Web Pages 2 websites using Visual Studio, which gives you enhanced IntelliSense capabilities and debugging. To work with Web Pages in Visual Studio, you must first install Visual Studio 2010 SP1, Visual Web Developer Express 2010 SP1, or Visual Studio 11 Beta. Then install the ASP.NET MVC 4 Beta, which includes templates and tools for creating ASP.NET MVC 4 and Web Pages 2 applications in Visual Studio. > > > *Last update: 18 June 2012* ## Installing WebMatrix To install Web Pages, you can use the Microsoft Web Platform Installer, which is a free application that makes it easy to install and configure web-related technologies. You will install the WebMatrix 2 Beta, which includes Web Pages 2 Beta. 1. Browse to the installation page for the latest version of the Web Platform Installer: [https://go.microsoft.com/fwlink/?LinkId=226883](https://go.microsoft.com/fwlink/?LinkId=226883) > [!NOTE] > If you already have WebMatrix 1 installed, this installation updates it to WebMatrix 2 Beta. You can run websites that were created using version 1 or 2 on the same computer. For more information, see the section on [Running Web Pages Applications Side by Side](#sidebyside). 2. Choose **Install Now**. If you use Internet Explorer, go to the next step. If you use a different browser like Mozilla Firefox or Google Chrome, you are prompted to save the *Webmatrix.exe* file to your computer. Save the file and then click it to launch the installer. 3. Run the installer and choose the **Install** button. This installs WebMatrix and Web Pages. ## New and Enhanced Features ### Changes for the RC Version (June 2012) The RC version release in June 2012 has a few changes from the Beta version refresh that was released in March 2012. These changes are: - A `Validation.AddFormError` method was added to the `Validation` helper. This is useful if you perform validation manually (for example, you validate a value that is passed in the query string) and you want to add an error message that can be displayed by the `Html.ValidationSummary` method. For more information, see the section [Validating Data That Doesn't Come Directly From Users](https://go.microsoft.com/fwlink/?LinkId=253002#Validating_Data_That_Doesnt_Come_Directly_from_Users) in [Validating User Input in ASP.NET Web Pages (Razor) Sites](https://go.microsoft.com/fwlink/?LinkId=253002). - The functionality for bundling and minification has been removed from the core ASP.NET Web Pages 2 assemblies. As a consequence, the `Assets` helper listed later in this document is not available. Instead, you must install the [ASP.NET Optimization](http://nuget.org/packages/Microsoft.Web.Optimization/0.1) NuGet package. For more information, see [Bundling and Minifying Assets in an ASP.NET Web Pages (Razor) Site](https://go.microsoft.com/fwlink/?LinkId=255373). - Additional assemblies to support ASP.NET Web Pages 2 have been added. The only noticeable effect of this change is that you might see more assemblies in a site's *bin* folder after you create a site or deploy a site to a hosting provider. ### Changes for the Beta Version (February 2012) The Beta version released in February 2012 has only a few changes from the Beta version that was released in December 2011. These changes are: - Razor now supports conditional attributes. In an HTML element, if you set an attribute to a value that resolves in server code to `false` or `null`, ASP.NET does not render the attribute at all. For example, imagine you have the following markup for a check box: [!code-html[Main](top-features-in-web-pages-2/samples/sample1.html)] If the value of `checked1` resolves to `false` or to `null`, the `checked` attribute is not rendered. This is a breaking change. - The `Validation.GetHtml` method has been renamed to `Validation.For`. This is a breaking change; `Validation.GetHtml` will not work in the Beta release. - You can now include the `~` operator in markup to reference the site root without using the `Href` function. (That is, the Razor parser can now find and resolve the `~` operator without requiring an explicit method call to `Href`.) The `Href` method still works, so this is not a breaking change. For example, if you previously had markup like this: `Home` You can now use markup like this: `Home` - The `Scripts` helper for assets (resource) management has been replaced with the `Assets` helper, which has slightly different methods, such as the following: - For `Scripts.Add`, use `Assets.AddScript` - For `Scripts.GetScriptTags`, use `Assets.GetScripts` This is a breaking change; the `Scripts` class is not available in the Beta release. The code examples in this document that use asset management have been updated with this change. ### Using the New and Updated Site Templates The **Starter Site** template has been updated so that it runs on Web Pages 2 by default. It also includes the following new capabilities: - Mobile-friendly page rendering. Through the use of CSS styles and the `@media` selector, the **Starter Site** provides improved rendering of pages on smaller screens, including mobile device screens. - Improved membership and authentication options. You can let users log into your site using their accounts from other social networking sites, such as Twitter, Facebook, and Windows Live. For more information, see the [Enabling Logins from Facebook and Other Sites using OAuth and OpenID](#oauthsetup) section. - HTML5 elements. The new **Personal Site** template lets you create a website that contains a personal blog, a photos page, and a Twitter page. You can customize a site based on the **Personal Site** template by doing the following: - Change the look of the site by editing the layout file (*\_SiteLayout.cshtml*) and the styles file (*Site.css*). - Install NuGet packages that add functionality to your site. For information about how to install packages, including the ASP.NET Web Helpers Library, see the tutorial about [installing helpers](https://go.microsoft.com/fwlink/?LinkId=202889#webhelpers). To access the **Personal Site** template, choose **Templates** on the WebMatrix **Quick Start** screen. [![topseven-personalsite-1](top-features-in-web-pages-2/_static/image2.png)](top-features-in-web-pages-2/_static/image1.png) In the **Templates** dialog box, choose the **Personal Site** template. [![topseven-personalsite-2](top-features-in-web-pages-2/_static/image4.png)](top-features-in-web-pages-2/_static/image3.png) The landing page of the **Personal Site** template lets you follow links to set up your blog, Twitter page, and photos page. [![topseven-personalsite-3](top-features-in-web-pages-2/_static/image6.png)](top-features-in-web-pages-2/_static/image5.png) ### Validating User Input In Web Pages 1, to validate user input on submitted forms, you use the `System.Web.WebPages.Html.ModelState` class. (This is illustrated in several of the code samples in the Web Pages 1 tutorial titled [Working with Data](../data/5-working-with-data.md).) You can still use this approach in Web Pages 2. However, Web Pages 2 also offers improved tools for validating user input: - New validation classes, including `System.Web.WebPages.ValidationHelper` and `System.Web.WebPages.Validator`, that let you do powerful validation tasks with a few lines of code. - Optionally, client-side validation, which provides immediate feedback to the user instead of requiring a round trip to the server to check for validation errors. (For security reasons, validation is performed on the server even if the checks have been performed in the client beforehand.) To use the new validation features, do the following: In the page's code, register an element to be validated by using methods of the `Validation` helper: `Validation.RequireField`, `Validation.RequireFields` (to register multiple elements to be required), or `Validation.Add`. The `Add` method lets you specify other types of validation checks, like data-type checking, comparing entries in different fields, string-length checks, and patterns (using regular expressions). Here are some examples: [!code-html[Main](top-features-in-web-pages-2/samples/sample2.html)] To display a field-specific error, call `Html.ValidationMessage` in the markup for each element being validated: [!code-cshtml[Main](top-features-in-web-pages-2/samples/sample3.cshtml)] To display a summary (`