Whats new in ASP.NET 4.0

2,059 views

Published on

Important Features of ASP.NET 4.0

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,059
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
39
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Whats new in ASP.NET 4.0

  1. 1. Whats new in ASP.NET 4.0 Quick Overview of Important Features Sunil Pottumuttu
  2. 2. ASP.NET 3.5 Service Pack 1 Microsoft Entity Framework ADO.NET Data Services Dynamic Data
  3. 3. Overview of Talk ASP.NET supports several very different types of web applications
  4. 4. Web.config File Refactoring<?xml version="1.0"?><configuration><system.web><compilation targetFramework="4.0" /></system.web></configuration>
  5. 5. Extensible Output Caching ASP.NET 4.0 OutputCacheProvider - create a custom output- cache provider as a class that derives from the new System.Web.Caching.OutputCacheProvider Providers for 3rd Party, Velocity, FileSystem
  6. 6. Output Caching Configuration<caching><outputCache defaultProvider="AspNetInternalProvider"><providers><add name="DiskCache"type="Test.OutputCacheEx.DiskOutputCacheProvider, DiskCacheProvider"/></providers></outputCache></caching>
  7. 7. Output Caching Configuration at Page Level<%@ OutputCache Duration="60" VaryByParam="None" providerName="DiskCache" %>
  8. 8. Auto-Start Web Applications Usual approach: Application_Start Auto-Start ASP.NET 4.0 + IIS 7.5 AppPool startMode set to “alwaysRunning” IIS Application Warm-Up Module for IIS 7.5 warm-up occurs during startup of the IIS service (if you configured the IIS application pool as AlwaysRunning) and when an IIS worker process recycles. During recycle, the old IIS worker process continues to execute requests until the newly spawned worker process is fully warmed up, so that applications experience no interruptions or other issues due to unprimed caches
  9. 9. IIS Configuration for the above In applicationHost.config<applicationPools><add name="MyApplicationPool" startMode="AlwaysRunning" /></applicationPools>
  10. 10. Permanently Redirecting a Page RedirectPermanent("/newpath/foroldcontent.aspx");
  11. 11. Session State Compression Used when state is out of porcess compressionEnabled in web.config DeflateStream/GZipStream Use System.IO.Compression.GZipStream Web.config<sessionState mode="SqlServer" sqlConnectionString="data source=dbserver;Initial Catalog=aspnetstate" allowCustomSqlDatabase="true" compressionEnabled="true“/>
  12. 12. Expanding the Range of Allowable URLs Previous versions of ASP.NET constrained URL path lengths to 260 characters, based on the NTFS file-path limit.<httpRuntime maxRequestPathLength="260" maxQueryStringLength="2048" />
  13. 13. Request Path Valid Chars 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<httpRuntime requestPathInvalidChars="&lt;,&gt;,*,%,&amp;,:,,?" /> By default, the requestPathInvalidChars attribute defines eight characters as invalid. (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.) You can customize the set of invalid characters as needed
  14. 14. Extensible Request ValidationSystem.Web.Util.RequestValidator<httpRuntime requestValidationType="Samples.MyValidator, Samples" />public class CustomRequestValidation : RequestValidator{protected override bool IsValidRequestString(HttpContext context, string value,RequestValidationSource requestValidationSource,string collectionKey,out int validationFailureIndex){...}}
  15. 15. Object Caching and Object Caching ExtensibilitySystem.Runtime.Caching.dllCan Implement MemoryCache
  16. 16. Extensible HTML, URL, and HTTP Header Encoding<httpRuntime encoderType="Samples.MyCustomEnco der, Samples" />You can create a custom encoder by deriving from the new System.Web.Util.HttpEncoder After a custom encoder has been configured, ASP.NET automatically calls the custom encoding implementation whenever public encoding methods of the System.Web.HttpUtility or System.Web.HttpServerUtility classes are called
  17. 17. Multi-Targeting• <compilation targetFramework="4.0"/>
  18. 18. jQuery Included with Web Forms and MVC jQuery-1.4.1.js – The human-readable, unminified version of the jQuery library. 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.
  19. 19. Content Delivery Network Support<script src="http://ajax.microsoft.com/ajax/jquery/jquery- 1.4.2.js" type="text/javascript"></script>Supports SSLMore Details here: http://www.asp.net/ajaxlibrary/CDN.ashxASP.NET ScriptManager supports the Microsoft Ajax CDN<asp:ScriptManager ID="sm1" EnableCdn="true" runat="server" />
  20. 20. ScriptManager Explicit Scripts<asp:ScriptManager ID="sm1" AjaxFrameworkMode="Explicit" runat="server"><Scripts><asp:ScriptReference Name="MicrosoftAjaxCore.js" /><asp:ScriptReference Name="MicrosoftAjaxComponentModel.js" /><asp:ScriptReference Name="MicrosoftAjaxSerialization.js" /><asp:ScriptReference Name="MicrosoftAjaxNetwork.js" /></Scripts></asp:ScriptManager>** ScriptManager.AjaxFrameworkMode
  21. 21. Setting Meta TagsPage.MetaKeywords and Page.MetaDescription Properties of Page class<meta name="keywords" content="These, are, my, keywords" /><meta name="description" content="This is the description of my page" /> OR<%@ Page Language="C#" AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"Keywords="These, are, my, keywords"Description="This is a description" %>
  22. 22. Enabling View State for Individual Controls ViewStateMode Property Enabled Disabled Inherit Enabled enables view state for that control and for any child controls that are set to Inherit or that have nothing set. Disabled disables view state, and Inherit specifies that the control uses the ViewStateMode setting from the parent control
  23. 23. ASP.NET Core Enhancements Cache Extensibility Auto-Start Web Applications Browser Capabilities Extensibility Session State Compression
  24. 24. ASP.NET Core Enhancements Cache Extensibility Auto-Start Web Applications Browser Capabilities Extensibility Session State Compression
  25. 25. Browser Definition Files blackberry.browser chrome.browser Default.browser firefox.browser gateway.browser generic.browser ie.browser iemobile.browser iphone.browser opera.browser safari.browser
  26. 26. Routing in ASP.NET 4public class Global : System.Web.HttpApplication{ void Application_Start(object sender, EventArgs e) { RouteTable.Routes.MapPageRoute("SearchRoute", "search/{searchterm}", "~/search.aspx"); RouteTable.Routes.MapPageRoute("UserRoute", "users/{username}", "~/users.aspx"); }}Equivalent asp.net 4RouteTable.Routes.Add("SearchRoute", new Route("search/{searchterm}",new PageRouteHandler("~/search.aspx")));string searchterm = Page.RouteData.Values["searchterm"] as string;
  27. 27. Accessing Routing Information in Markup<asp:HyperLink ID="HyperLink1" runat="server"NavigateUrl="<%$RouteUrl:SearchTerm=scott%>"> Search for Scott</asp:HyperLink>
  28. 28. Setting Client IDs Predictable Client ID’s<%@ Page Language="C#" AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"ClientIDMode="Predictable" %>OR<system.web><pages clientIDMode="Predictable"></pages></system.web>
  29. 29. Chart Control 35 distinct chart types. An unlimited number of chart areas, titles, legends, and annotations. A wide variety of appearance settings for all chart elements. 3-D support for most chart types. More than 50 financial and statistical formulas for data analysis and transformation. State management. Binary streaming.
  30. 30. New Syntax for HTML Encoded ExpressionsOld Style<%= HttpUtility.HtmlEncode(expression) %>New style<%: expression %>
  31. 31. Project Template ChangesWeb Site project or Web Application project
  32. 32. Empty Web Application Template
  33. 33. Web Application and Web Site Project Templates
  34. 34. Dynamic Data•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 theGridView and DetailsView controls by using field templates that are part ofyour Dynamic Data project.

×