- ASP.NET Core Services
- ASP.NET Web Forms
- ASP.NET MVC
- Dynamic Data
- ASP.NET Chart Control
- Visual Web Developer Enhancements
- Web Application Deployment with Visual Studio 2010
- Enhancements to ASP.NET Multi-Targeting
Web.config File Refactoring
ASP.NET 4 adds extensibility to output caching that enables you to configure one or more custom output-cache providers. Output-cache providers can use any storage mechanism to persist HTML content. These storage options can include local or remote disks, cloud storage, and distributed cache engines.
Output-cache provider extensibility in ASP.NET 4 lets you design more aggressive and more intelligent output-caching strategies for Web sites. For example, you can create an output-cache provider that caches the "Top 10" pages of a site in memory, while caching pages that get lower traffic on disk. Alternatively, you can cache every vary-by combination for a rendered page, but use a distributed cache so that the memory consumption is offloaded from front-end Web servers.
You create a custom output-cache provider as a class that derives from the OutputCacheProvider type. You can then configure the provider in the Web.config file by using the new providers subsection of the outputCache element
For more information and for examples that show how to configure the output cache, see outputCache Element for caching (ASP.NET Settings Schema). For more information about the classes that support caching, see the documentation for the OutputCache and OutputCacheProvider classes.
By default, in ASP.NET 4, all HTTP responses, rendered pages, and controls use the in-memory output cache. The defaultProvider attribute for ASP.NET is AspNetInternalProvider. You can change the default output-cache provider used for a Web application by specifying a different provider name for defaultProvider attribute.
In addition, you can select different output-cache providers for individual control and for individual requests and programmatically specify which provider to use. For more information, see the HttpApplication.GetOutputCacheProviderName(HttpContext) method. The easiest way to choose a different output-cache provider for different Web user controls is to do so declaratively by using the new providerName attribute in a page or control directive, as shown in the following example:
Auto-Start Web Applications
To address this scenario, a new auto-start feature is available when ASP.NET 4 runs on IIS 7.5 on Windows Server 2008 R2. The feature provides a controlled approach for starting up an application pool, initializing an ASP.NET application, and then accepting HTTP requests. It lets you perform expensive application initialization prior to processing the first HTTP request.
For more information about the auto-start feature, see the What's New for ASP.NET 4 White Paper.
Permanently Redirecting a Page
In ASP.NET, developers have traditionally handled requests to old URLs by using the Redirect method to forward a request to the new URL. However, the Redirect method issues an HTTP 302 (Found) response (which is used for a temporary redirect). This results in an extra HTTP round trip.
ASP.NET 4 adds a RedirectPermanent helper method that makes it easy to issue HTTP 301 (Moved Permanently) responses, as in the following example:
Session State Compression
Because both options store state information outside a Web application's worker process, session state has to be serialized before it is sent to remote storage. If a large amount of data is saved in session state, the size of the serialized data can become very large.
ASP.NET 4 introduces a new compression option for both kinds of out-of-process session state providers. By using this option, applications that have spare CPU cycles on Web servers can achieve substantial reductions in the size of serialized session state data.
You can set this option using the new compressionEnabled attribute of the sessionState element in the configuration file. When the compressionEnabled configuration option is set to true, ASP.NET compresses (and decompresses) serialized session state by using the .NET Framework GZipStreamclass.
Expanding the Range of Allowable URLs
ASP.NET 4 also enables you to configure the characters that are used by the URL character check. When ASP.NET finds an invalid character in the path portion of a URL, it rejects the request and issues an HTTP 400 (Bad request) status code. In previous versions of ASP.NET, the URL character checks were limited to a fixed set of characters. In ASP.NET 4, you can customize the set of valid characters using the new requestPathInvalidChars attribute of the httpRuntime configuration element, as shown in the following example:
(In the string that is assigned to requestPathInvalidChars by default, the less than (<), greater than (>), and ampersand (&) characters are encoded, because the Web.config file is an XML file.) By default, the requestPathInvalidChars attribute defines eight characters as invalid.
|ASP.NET 4 always rejects URL paths that contain characters in the ASCII range of 0x00 to 0x1F, because those are invalid URL characters as defined in RFC 2396 of the IETF (see http://www.ietf.org/rfc/rfc2396.txt on the IETF Web site). On versions of Windows Server that run IIS 6 or higher, the http.sys protocol device driver automatically rejects URLs that contain these characters.|
Object Caching and Object Caching Extensibility
- Abstract types that provide the foundation for building any type of custom cache implementation.
- A concrete in-memory object cache implementation (the MemoryCache class).
Extensible HTML, URL, and HTTP Header Encoding
- HTML encoding.
- URL encoding.
- HTML attribute encoding.
- Encoding outbound HTTP headers.
After a custom encoder has been configured, ASP.NET automatically calls the custom encoding implementation whenever public encoding methods of the HttpUtility or HttpServerUtility classes are called. This lets one part of a Web development team create a custom encoder that implements aggressive character encoding, while the rest of the Web development team continues to use the public ASP.NET encoding APIs. By centrally configuring a custom encoder in the httpRuntime element, you are guaranteed that all text-encoding calls from the public ASP.NET encoding APIs are routed through the custom encoder.
Performance Monitoring for Individual Applications in a Single Worker Process
ASP.NET 4 leverages new resource-monitoring functionality introduced by the CLR. To enable this functionality, you can add the following XML configuration snippet to the aspnet.config configuration file.
(The aspnet.config file is in the directory where the .NET Framework is installed. It is not the application Web.config file.) When the appDomainResourceMonitoring feature has been enabled, two new performance counters are available in the "ASP.NET Applications" performance category: % Managed Processor Time and Managed Memory Used. Both of these performance counters use the new CLR application-domain resource management feature to track estimated CPU time and managed memory utilization of individual ASP.NET applications. As a result, with ASP.NET 4, administrators now have a more granular view into the resource consumption of individual applications running in a single worker process.
jQuery Included with Web Forms and MVC
- jQuery-1.4.1.js – The human-readable, unminified version of the jQuery library. (Minification is the practice of removing unnecessary characters from code to reduce its size and thereby improve load and execution times.)
- jQuery-14.1.min.js – The minified version of the jQuery library.
- jQuery-1.4.1-vsdoc.js – The IntelliSense documentation file for the jQuery library.
Content Delivery Network Support
ScriptManager Explicit Scripts
- The ability to set meta tags.
- More control over view state.
- Support for recently introduced browsers and devices.
- Easier ways to work with browser capabilities.
- Support for using ASP.NET routing with Web Forms.
- More control over generated IDs.
- The ability to persist selected rows in data controls.
- More control over rendered HTML in the FormView and ListView controls.
- Filtering support for data source controls.
- Enhanced support for Web standards and accessibility.
- Project template changes.
Setting Meta Tags with the Page.MetaKeywords and Page.MetaDescription Properties
These two properties work like the Title property does, and they can be set in the @ Page directive. For more information, see Page.MetaKeywords and Page.MetaDescription.
Enabling View State for Individual Controls
View state data is included in a page's HTML and increases the amount of time it takes to send a page to the client and post it back. Storing more view state than is necessary can cause significant decrease in performance. In earlier versions of ASP.NET, you could reduce the impact of view state on a page's performance by disabling view state for specific controls. But sometimes it is easier to enable view state for a few controls that need it instead of disabling it for many that do not need it.
For more information, see Control.ViewStateMode.
Support for Recently Introduced Browsers and Devices
The browser definition files that are included with ASP.NET 4 are shown in the following list:
A New Way to Define Browser Capabilities
In ASP.NET version 3.5 Service Pack 1, you define browser capabilities in an XML file. This file resides in a machine-level folder or an application-level folder. Most developers do not need to customize these files, but for those who do, the provider approach can be easier than dealing with complex XML syntax. The provider approach makes it possible to simplify the process by implementing a common browser definition syntax, or a database that contains up-to-date browser definitions, or even a Web service for such a database.
For more information about the new browser capabilities provider, see the What's New for ASP.NET 4 White Paper.
Routing in ASP.NET 4
For example, the URL for a page that displays product categories in your application might look like the following example:
By using routing, you can use the following URL to render the same information:
The second URL lets the user know what to expect and can result in significantly improved rankings in search engine results.
the new features include the following:
- The PageRouteHandler class is a simple HTTP handler that you use when you define routes. You no longer have to write a custom route handler.
- The HttpRequest.RequestContext and Page.RouteData properties make it easier to access information that is passed in URL parameters.
- The RouteUrl expression provides a simple way to create a routed URL in markup.
- The RouteValue expression provides a simple way to extract URL parameter values in markup.
- The RouteUrl expression provides a simple way to create a routed URL in markup.
- The RouteParameter class makes it easier to pass URL parameter values to a query for a data source control (similar to FormParameter).
- You no longer have to change the Web.config file to enable routing.
Setting Client IDs
Typically you get a reference to an HTML element in client script by using the document.GetElementById method. You pass to this method the value of the id attribute of the HTML element you want to reference. In the case of elements that are rendered for ASP.NET server controls earlier versions of ASP.NET could make this difficult or impossible. You were not always able to predict what id values ASP.NET would generate, or ASP.NET could generate very long id values. The problem was especially difficult for data controls that would generate multiple rows for a single instance of the control in your markup.
ASP.NET 4 adds two new algorithms for generating id attributes. These algorithms can generate id attributes that are easier to work with in client script because they are more predictable and that are easier to work with because they are simpler. For more information about how to use the new algorithms, see the following topics:
Persisting Row Selection in Data Controls
FormView Control Enhancements
For more information, see FormView Web Server Control Overview.
ListView Control Enhancements
In ASP.NET 4, the ListView control does not require a layout template. The markup shown in the previous example can be replaced with the following markup:
For more information, see ListView Web Server Control Overview.
Filtering Data with the QueryExtender Control
To make filtering easier, a new QueryExtender control has been added in ASP.NET 4. This control can be added to EntityDataSource or LinqDataSource controls in order to filter the data returned by these controls. Because the QueryExtender control relies on LINQ, but you do not to need to know how to write LINQ queries to use the query extender.
The QueryExtender control supports a variety of filter options. The following lists QueryExtender filter options.
|SearchExpression||Searches a field or fields for string values and compares them to a specified string value.|
|RangeExpression||Searches a field or fields for values in a range specified by a pair of values.|
|PropertyExpression||Compares a specified value to a property value in a field. If the expression evaluates to true, the data that is being examined is returned.|
|OrderByExpression||Sorts data by a specified column and sort direction.|
|CustomExpression||Calls a function that defines custom filter in the page.|
Enhanced Support for Web Standards and Accessibility
For details about how the HTML that is rendered by each control meets accessibility standards, see ASP.NET Controls and Accessibility.
CSS for Controls that Can be Disabled
Text="Test" Enabled="false" />
In ASP.NET 3.5, the previous control settings generate the following HTML:
In HTML 4.01, the disabled attribute is not considered valid on span elements. It is valid only on input elements because it specifies that they cannot be accessed. On display-only elements such as span elements, browsers typically support rendering for a disabled appearance, but a Web page that relies on this non-standard behavior is not robust according to accessibility standards.
For display-only elements, you should use CSS to indicate a disabled visual appearance. Therefore, by default ASP.NET 4 generates the following HTML for the control settings shown previously:
You can change the value of the class attribute that is rendered by default when a control is disabled by setting the DisabledCssClass property.
CSS for Validation Controls
ErrorMessage="Required Field" ControlToValidate="RadioButtonList1" />
ASP.NET 3.5 renders the following HTML for the validator control:
By default, ASP.NET 4 does not render an inline style to set the color to red. An inline style is used only to hide or show the validator, as shown in the following example:
Therefore, ASP.NET 4 does not automatically show error messages in red. For information about how to use CSS to specify a visual style for a validation control, see Validating User Input in ASP.NET Web Pages.
CSS for the Hidden Fields Div Element
CSS for the Table, Image, and ImageButton Controls
The Image control and the ImageButton control also do this. Because this is not necessary and provides visual formatting information that should be provided by using CSS, the attribute is not generated in ASP.NET 4.
CSS for the UpdatePanel and UpdateProgress Controls
The following HTML is rendered for this markup:
Eliminating Unnecessary Outer Tables
If you use templates to customize the appearance of these controls, you can specify CSS styles in the markup that you provide in the templates. In that case, no extra outer table is required. In ASP.NET 4, you can prevent the table from being rendered by setting the new RenderOuterTable property to false.
Layout Templates for Wizard Controls
New HTML Formatting Options for the CheckBoxList and RadioButtonList Controls
- UnorderedList. This option causes the HTML output to be formatted by using ul and li elements instead of a table.
- OrderedList. This option causes the HTML output to be formatted by using ol and li elements instead of a table.
Header and Footer Elements for the Table Control
CSS and ARIA Support for the Menu Control
- The generated HTML is structured as an unordered list (ul and li elements).
- CSS is used for visual formatting.
- The menu behaves in accordance with ARIA standards for keyboard access. You can use arrow keys to navigate menu items. (For information about ARIA, see Accessibility in Visual Studio and ASP.NET.)
Valid XHTML for the HtmlForm Control
Maintaining Backward Compatibility in Control Rendering
If this setting is omitted, the default value is the same as the version of ASP.NET that the Web site targets. (For information about multi-targeting in ASP.NET, see .NET Framework Multi-Targeting for ASP.NET Web Projects.)
- Empty Web Application and Web Site Project Templates. These are similar to the Empty Web Site layout from earlier versions of ASP.NET, except they contain a Web.config file that specifies the targeted version of the .NET Framework.
- Web Application and Web Site Project Templates. These include a number of files that were not created in earlier versions. The additional files provide basic membership functionality, a master page and content pages that use it, AJAX and CSS files. The intention of these changes to the project templates is to provide guidance on how to start building a new Web application.,
- A RAD experience for quickly building a data-driven Web site.
- Automatic validation that is based on constraints defined in the data model.
- The ability to easily change the markup that is generated for fields in the GridView and DetailsView controls by using field templates that are part of your Dynamic Data project.
Enabling Dynamic Data for Individual Data-Bound Controls in Existing Web Applications
- Setting default values for data fields. Dynamic Data enables you to provide default values at run time for fields in a data control.
- Interacting with the database without creating and registering a data model.
- Automatically validating the data that is entered by the user without writing any code.
Declarative DynamicDataManager Control Syntax
This markup enables Dynamic Data behavior for the GridView1 control that is referenced in the DataControls section of the DynamicDataManager control.
For more information about entity templates, see ASP.NET 4 and Visual Studio 2010 Web Development Overview (.pdf format) on the ASP.NET Web site.
New Field Templates for URLs and E-mail Addresses
The following example shows how to mark fields.
Creating Links with the DynamicHyperLink Control
For information, see How to: Create Table Action Links in Dynamic Data
Support for Inheritance in the Data Model
For more information, see Walkthrough: Mapping Table-per-Hierarchy Inheritance in Dynamic Data.
Support for Many-to-Many Relationships (Entity Framework Only)
For more information, see Working with Many-to-Many Data Relationships in Dynamic Data.
New Attributes to Control Display and Support Enumerations
The EnumDataTypeAttribute class has been added to let you map fields to enumerations. When you apply this attribute to a field, you specify an enumeration type. Dynamic Data uses the new Enumeration.ascx field template to create UI for displaying and editing enumeration values. The template maps the values from the database to the names in the enumeration.
Enhanced Support for Filters
An additional enhancement is that filtering support has been rewritten to use the new QueryExtender feature of Web Forms. This lets you create filters without requiring knowledge of the data source control that the filters will be used with. Along with these extensions, filters have also been turned into template controls, which lets you add new ones. Finally, the DisplayAttribute class mentioned earlier allows the default filter to be overridden, in the same way that UIHint allows the default field template for a column to be overridden.
For more information, see Walkthrough: Filtering Rows in Tables That Have a Parent-Child Relationship and QueryableFilterRepeater.
- Data series, chart areas, axes, legends, labels, titles, and more.
- Data binding.
- Data manipulation, such as copying, splitting, merging, alignment, grouping, sorting, searching, and filtering.
- Statistical formulas and financial formulas.
- Advanced chart appearance, such as 3-D, anti-aliasing, lighting, and perspective.
- Events and customizations.
- Interactivity and Microsoft Ajax.
- Support for the Ajax Content Delivery Network (CDN), which provides an optimized way for you to add Microsoft Ajax Library and jQuery scripts to your Web applications.
Improved CSS Compatibility
Visual Studio 2010 includes over 200 snippets that help you auto-complete common ASP.NET and HTML tags, including required attributes (such as runat="server") and common attributes specific to a tag (such as ID, DataSourceID, ControlToValidate, and Text).
You can download additional snippets, or you can write your own snippets that encapsulate the blocks of markup that you or your team use for common tasks. For more information on HTML snippets, see Walkthrough: Using HTML Snippets.
- Creating an IIS application on the destination computer and configuring IIS settings.
- Copying files to the destination computer.
- Changing Web.config settings that must be different in the destination environment.
- Propagating changes to data or data structures in SQL Server databases that are used by the Web application.