SlideShare a Scribd company logo
1 of 31
Download to read offline
ASP.NET 4+ Overview

Alvin Lau
Solutions Consultant, Datacraft
MVP (ASP.NET/IIS) since Jul 2005
SGDOTNET Council Member
microlau@sgdotnet.org
ASP.NET 4+ Overview
Agenda

•   Advancements in ASP.NET 4.0
•   ASP.NET MVC 3.0
•   Questions and Answers
Advancements in ASP.NET 4.0
Advancements in ASP.NET 4.0
Overview

•   Core Services
•   Ajax
•   Web forms
•   Dynamic Data
•   Web Application Deployment
Advancements in ASP.NET 4.0
Core Services

                                  <?xml version="1.0"?>
   Web.config file refactoring     <configuration>
                                     <system.web>
                                      <compilation targetFramework="4.0" />
                                     </system.web>
                                    </configuration>

   Extensible Output Caching
    <caching>
      <outputCache defaultProvider="AspNetInternalProvider">
        <providers>
          <add name=“DiskCache”
    type="Test.OutputCacheEx.DiskOutputCacheProvider, DiskCacheProvider"/>
        </providers>
      </outputCache>
    </caching>

    <%@ OutputCache Duration="60" VaryByParam="None" providerName="DiskCache"
    %>


    public override string GetOutputCacheProviderName(HttpContext context)
    {
        if (context.Request.Path.EndsWith("Advanced.aspx"))
Advancements in ASP.NET 4.0
Core Services

   Auto-start    (applicationHost.config)
                  <applicationpools>
                    <add name="MyApplicationPool" startMode="AlwaysRunning" />
                  </applicationpools>

    <sites>
     public name="MySite" id="1">
      <site class CustomInitialization :
     System.Web.Hosting.IProcessHostPreloadClient
        <application path="/"
     {    serviceAutoStartEnabled="true"
       public void Preload(string[] parameters)
          serviceAutoStartProvider="PrewarmMyCache" >
       { <!-- Additional content -->
         // Perform initialization.
        </application>
       }
      </site>
     }
    </sites>

    <!-- Additional content -->
    <serviceautostartproviders>
      <add name="PrewarmMyCache"
        type="MyNamespace.CustomInitialization, MyLibrary" />
    </serviceautostartproviders>
Advancements in ASP.NET 4.0
Core Services

   RedirectPermanent helper (Issue HTTP 301 Moved Permanently
    Response)
   Shrinking Session State (Using System.IO.Compression.GZipStream
    class)
    <sessionState
       mode="SqlServer"
       sqlConnectionString="data source=dbserver;Initial
    Catalog=aspnetstate"
       allowCustomSqlDatabase="true"
       compressionEnabled="true"
    />
Advancements in ASP.NET 4.0
Core Services

•   Performance Monitoring (new performance counters)
    – % Managed Processor Time
    – Managed Memory Use

    Aspnet.config
    <?xml version="1.0" encoding="UTF-8" ?>
    <configuration>
      <runtime>
        <appDomainResourceMonitoring enabled="true"/>
      </runtime>
    </configuration>
Advancements in ASP.NET 4.0
<%@ Page Language="C#" ... >
Ajax
<head runat="server">
 Open-source jQuery</title>
     <title>Show Jquery
</head>
  – jQuery-1.4.1.js
<body>
     <form id="form1" runat="server">
  – jQuery-1.4.1.min.js
     <div>
  – jQuery-1.4.1-vsdoc.js
         <asp:TextBox ID="txtFirstName"ID="sm1" EnableCdn="true" runat="server"
                    <asp:ScriptManager runat="server" />
                    <script src="http://ajax.microsoft.com/ajax/jquery/jquery-
 CDN Support
         <br />     1.4.2.js" type="text/javascript"></script>
                    />
         <asp:TextBox ID="txtLastName" runat="server" />
     </div>
 Script Manager Explicit Scripts
     </form>
  <asp:ScriptManager ID="sm1" AjaxFrameworkMode="Explicit"
     <script src="Scripts/jquery-1.4.1.js"
  runat="server">
type="text/javascript"></script>

  <Scripts> type="text/javascript">
    <script
      <asp:ScriptReferencefunction() { $(this).css("background-color",
        $("input").focus( Name="MicrosoftAjaxCore.js" />
      <asp:ScriptReference Name="MicrosoftAjaxComponentModel.js" />
"yellow"); });
      <asp:ScriptReference Name="MicrosoftAjaxSerialization.js" />
      <asp:ScriptReference Name="MicrosoftAjaxNetwork.js" />
    </script>
  </Scripts>
</body>
  </asp:ScriptManager>
</html>
Advancements in ASP.NET 4.0
Web Forms

   Set meta tags
    <%@ Page Language="C#" AutoEventWireup="true"
      CodeFile="Default.aspx.cs"
      Inherits="_Default"
      Keywords="These, are, my, keywords"
      Description="This is a description" %>


   View State for Individual Controls
     ViewStateMode   (Enabled, Disabled, Inherit)
    <asp:PlaceHolder ID="PlaceHolder1" runat="server"
     <%@ Page Language="C#" AutoEventWireup="true"
    ViewStateMode="Disabled">
       CodeBehind="Default.aspx.cs"
    <asp:PlaceHolder ID="PlaceHolder2" runat="server"
       Inherits="WebApplication1._Default"
    ViewStateMode="Enabled">
       ViewStateMode="Disabled" %>
Advancements in ASP.NET 4.0
Web Forms

    public class CustomProvider : HttpCapabilitiesEvaluator
   Browser Capabilities Providers
    {
     Replacing ASP.NET Browser Capabilities
      public override HttpBrowserCapabilities
      1. GetBrowserCapabilities(HttpRequest request) and overrides
          Create provider class from HttpCapabilitiesProvider
         {
          GetBrowserCapabilities method
           HttpBrowserCapabilities browserCaps =
      2. Register provider with application
             base.GetHttpBrowserCapabilities(request);
         – if (browserCaps.Browser == "Unknown")
           browserCaps section in web.config or machine.config
           {
         – Write code in Application_Start (Global.asax)
             browserCaps = MyBrowserCapabilitiesEvaulator(request);
           }
      Caching HttpBrowserCapabilities Object (same process)
         return browserCaps;
     Extending ASP.NET Browser Capabilities (same process)
      }
    }
Advancements in ASP.NET 4.0
Web Forms

   Easier to useGlobal : System.Web.HttpApplication
    public class
                   routing
    { protected void Page_Load(object sender, EventArgs   e)
        <asp:sqldatasource id="SqlDataSource1" runat="server"
      {void Application_Start(object sender, EventArgs e)
     PageRouteHandler class
             connectionstring="<%$ ConnectionStrings:MyNorthwind %>"
       { string searchterm = Page.RouteData.Values["searchterm"] as
             selectcommand="SELECT CompanyName,ShipperID FROM Shippers
     New properties - HttpRequest.RequestContext, Page.RouteData
      string;
          RouteTable.Routes.MapPageRoute("SearchRoute",
        where
         label1.Text = builders -
            expression searchterm;
     New "search/{searchterm}", "~/search.aspx");
               CompanyName=@companyname"
      } RouteTable.Routes.MapPageRoute("UserRoute",
      System.Web.Compilation.RouteUrlExpressionBuilder,
           <selectparameters>
            "users/{username}", "~/users.aspx");
             <asp:routeparameter name="companyname" RouteKey="searchterm"
      System.Web.Compilation.RouteValueExpressionBuilder
      http://localhost/search/scott
       }
        />
    } RouteUrl
          </selectparameters>
     RouteValue
    RouteTable.Routes.Add("SearchRoute", new
        </asp:sqldatasource>
      <asp:HyperLink ID="HyperLink1" runat="server"
    Route("search/{searchterm}",
     RouteParameter class
         NavigateUrl="<%$RouteUrl:SearchTerm=scott%>">Search for
       new PageRouteHandler("~/search.aspx")));
      Scott</asp:HyperLink>

     http://localhost/search/scott
Advancements in ASP.NET 4.0
Web Forms

•   <tc:NamingPanel runat="server" ID="ParentPanel"
    Setting Client IDs (ClientIDMode property)
    ClientIDMode="Static">
    – AutoID (legacy) runat="server" ID="NamingPanel1"
       <tc:NamingPanel
    ClientIDMode="Predictable">
    – Static
         <asp:TextBox ID="TextBox1" runat="server"
    – Predictable
    Text="Hello!"></asp:TextBox>
       </tc:NamingPanel>
    – Inherit
    </tc:NamingPanel>
    <%@ Page Language="C#" AutoEventWireup="true"
      <system.web>
       CodeFile="Default.aspx.cs"
        <pages clientIDMode="Predictable"></pages>
       Inherits="_Default"
    <div id="ParentPanel">
      </system.web>
       ClientIDMode="Predictable" %>
      <div id="ParentPanel_NamingPanel1">
        <input
    name="ctl00$ContentPlaceHolder1$ParentPanel$NamingPanel1$TextBox
    1"
            type="text" value="Hello!"
    id="ParentPanel_NamingPanel1_TextBox1" />
    </div>
Advancements in ASP.NET 4.0
Web Forms

   ASP.NET Chart Controls
Advancements in ASP.NET 4.0
Web Forms

•   QueryExtender Control
    <asp:LinqDataSource ID="dataSource" runat="server">
    TableName="Products"> ID="dataSource" runat="server">
     <asp:LinqDataSource
     TableName="Products"> ID="dataSource" runat="server"
       <asp:LinqDataSource
    </asp:LinqDataSource>
       TableName="Products"> ID="dataSource" runat="server"
         <asp:LinqDataSource
     </asp:LinqDataSource>
    <asp:QueryExtender TargetControlID="dataSource" runat="server">
         TableName="Products">
       </asp:LinqDataSource>
     <asp:QueryExtender TargetControlID="dataSource" runat="server">
      <asp:SearchExpression DataFields="ProductName,
         </asp:LinqDataSource>
       <asp:QueryExtender TargetControlID="dataSource" runat="server">
        <asp:RangeExpression DataField="UnitPrice" MinType="Inclusive"
    Supplier.CompanyName" TargetControlID="dataSource" runat="server">
         <asp:QueryExtender
           <asp:PropertyExpression>
             MaxType="Inclusive">
            SearchType="StartsWith">
            <asp:CustomExpression OnQuerying="FilterProducts" />
               <asp:ControlParameter ControlID="CheckBoxDiscontinued"
         <asp:ControlParameter ControlID="TextBoxSearch" />
           <asp:ControlParameter ControlID="TextBoxFrom" />
         </asp:QueryExtender>
       Name="Discontinued" />
      </asp:SearchExpression> ControlID="TexBoxTo" />
           <asp:ControlParameter
           </asp:PropertyExpression>
        </asp:RangeExpression>
    </asp:QueryExtender>
         protected void FilterProducts(object sender,
       </asp:QueryExtender>
     </asp:QueryExtender>
         CustomExpressionEventArgs e)
         {
            e.Query = from p in e.Query.Cast()
                where p.UnitPrice >= 10
                select p;
         }
Advancements in ASP.NET 4.0
Dynamic Data

   Enable on any ASP.NET application
    <asp:GridView ID="GridView1" runat="server"
    AutoGenerateColumns="True"
        DataKeyNames="ProductID" DataSourceID="LinqDataSource1">
    </asp:GridView>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server"
        ContextTypeName="DataClassesDataContext" EnableDelete="True"
    EnableInsert="True"
        EnableUpdate="True" TableName="Products">

    </asp:LinqDataSource>

    GridView1.EnableDynamicData (typeof(Product));

    DetailsView1.EnableDynamicData(typeof(Product), new {
    ProductName = "DefaultName" });
Enhancements with ASP.NET 4.0
Web App Deployment

   Web Packaging                                      Debug

   Web.config transformation
   Database deployment
                                             Testing   Web.config   Release
   One-click publish for web applications



                                                       Staging
Advancements in ASP.Net 4.0
Many more…


   Core                                                              Dynamic                Web App
                            Ajax          Web Forms
  Services                                                            Data                 Deployment
  Extensible Request
                                                                      Declarative syntax     Web Packaging
      Validation
                             jQuery       Persisting Row Selection

Range of allowable URLs                                               Entity templates
                                                                                                Web.config
                                                                                             transformations

    Object caching            CDN           CSS Improvements         New Field templates

                                                                                             DB deployment
 Extensible HTML, URL,
                                                                        Creating links
 HTTP Header Encoding
                                                Rendering
                          ScriptManager
                                              Improvements                                  One-Click Publish
    Multi-targeting                                                   Support M:M (EF)
ASP.NET MVC 3.0
ASP.NET MVC 3.0
Overview

   Razor View Engine
   Controller improvements
   Model validation improvements
   Nuget integration
   Partial page output caching
   Scaffolding improvements
ASP.NET MVC 3.0
Razor View Engine

   New view engine (Razor syntax)
   Includes IntelliSense and color colorisation for Razor syntax
   Can be unit tested
   Includes HTML helpers
     Chart,   WebGrid, Crypto, WebImage, WebMail
Demo – Razor View Engine
ASP.NET MVC 3.0
Controller Improvements

   Global Action Filters
    public static void RegisterGlobalFilters(GlobalFilterCollection
    filters)
    {
        filters.Add(new HandleErrorAttribute());
        filters.Add(new HandleLoggingAttribute());
    }

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);
    }
ASP.NET MVC 3.0
Controller Improvements

   “ViewBag” property
        public ActionResult Index()
    {
           ViewBag.Message = "Welcome to ASP.NET MVC!";

           return View();
    }

   “ActionResult” types
     HttpNotFoundResult   class – HTTP 404
     HttpRedirectResult class has boolean “Permanent” property – HTTP 302 or
      HTTP 301
    public ActionResult Test(int id)
    {
        return HttpNotFound();
    }
ASP.NET MVC 3.0
Controller Improvements

   JavaScript and Ajax improvements
   Client-side validation enabled by default
   Remote validator
    public class User
    {
        [Remote("UserNameAvailable", "Users")]
        public string UserName { get; set; }
    }
Demo – Remote Validator
ASP.NET MVC 3.0
   Controller Improvements

      JSON Binding support
 jQuery("#ajaxGrid").jqGrid({
        url: '@Url.Action("GridData")',
        datatype: "json",
        jsonReader: { repeatItems: false, id: "EventId" },
        colNames: ['EventId', 'EventName', 'EventDate', 'StartTime', 'EndTime',
'AllDay'],
        colModel: [
            { name: 'EventId', editable: true, sortable: false, hidden: true },
            { name: 'EventName', editable: true, sortable: false, hidden: false },
            { name: 'EventDate', editable: true, sortable: false, hidden: false },
            { name: 'StartTime', editable: true, sortable: false, hidden: false },
            { name: 'EndTime', editable: true, sortable: false, hidden: false },
            { name: 'AllDay', editable: true, sortable: false, hidden: false },
        ],
        rowNum: 3,
        pager: '#ajaxGridPager',
        width: '850',
        height: '10.5em'
    }),
ASP.NET MVC 3.0
Model Validation Improvements

   “DataAnnotations” metadata attributes
   “ValidationAttribute” Class
    public class User {
        [Required]
        public string Password { get; set; }
        [Required, Compare("Password")]
        public string ComparePassword { get; set; }
    }

   Validation Interfaces
     IValidatableObject, IClientValidatable   interfaces
   Dependency Injection Improvements
ASP.NET MVC 3.0
Other new features

   NuGet Integration
   Partial-Page Output Caching
    [OutputCache(Duration = 3600, VaryByParam = "id")]
    public ViewResult Details(int id)
    {
        return View(personRepository.GetById(id));
    }


   Scaffolding Improvements
Resources

   Overview of ASP.NET 4 and VS 2010 Web Development
    http://www.asp.net/learn/whitepapers/aspnet4#0.2__Toc253429246
   Unobstrusive JavaScript
    http://en.wikipedia.org/wiki/Unobtrusive_JavaScript
   ASP.NET MVC 3
    http://www.asp.net/mvc/mvc3#overview
    http://msdn.microsoft.com/en-us/library/gg416514(v=VS.98).aspx
   ASP.NET MVC 3.0 Service Location (Dependency Injection)
    http://bradwilson.typepad.com/blog/2010/07/service-location-pt1-introduction.html
   Steven Sanderson’s Blog about MVC Scaffolding
    http://blog.stevensanderson.com/category/scaffolding/
Alvin Lau
Solutions Consultant,
Datacraft
MVP (ASP.NET/IIS)
SGDOTNET Council Member
microlau@sgdotnet.org

More Related Content

What's hot

Ajax control asp.net
Ajax control asp.netAjax control asp.net
Ajax control asp.netSireesh K
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controlsRaed Aldahdooh
 
ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008Caleb Jenkins
 
05.SharePointCSOM
05.SharePointCSOM05.SharePointCSOM
05.SharePointCSOMEaswariSP
 
Harish Aspnet Deployment
Harish Aspnet DeploymentHarish Aspnet Deployment
Harish Aspnet Deploymentrsnarayanan
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC eldorina
 
Asp .net web form fundamentals
Asp .net web form fundamentalsAsp .net web form fundamentals
Asp .net web form fundamentalsGopal Ji Singh
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantNitin Sawant
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentChui-Wen Chiu
 
ASP.NET MVC and ajax
ASP.NET MVC and ajax ASP.NET MVC and ajax
ASP.NET MVC and ajax Brij Mishra
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentRob Windsor
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performancerudib
 

What's hot (20)

Walther Aspnet4
Walther Aspnet4Walther Aspnet4
Walther Aspnet4
 
Walther Ajax4
Walther Ajax4Walther Ajax4
Walther Ajax4
 
Ajax control asp.net
Ajax control asp.netAjax control asp.net
Ajax control asp.net
 
ASP.NET Lecture 1
ASP.NET Lecture 1ASP.NET Lecture 1
ASP.NET Lecture 1
 
Ajax and ASP.NET AJAX
Ajax and ASP.NET AJAXAjax and ASP.NET AJAX
Ajax and ASP.NET AJAX
 
Asp
AspAsp
Asp
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controls
 
ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008
 
05.SharePointCSOM
05.SharePointCSOM05.SharePointCSOM
05.SharePointCSOM
 
Harish Aspnet Deployment
Harish Aspnet DeploymentHarish Aspnet Deployment
Harish Aspnet Deployment
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Asp .net web form fundamentals
Asp .net web form fundamentalsAsp .net web form fundamentals
Asp .net web form fundamentals
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component Development
 
ASP.NET MVC and ajax
ASP.NET MVC and ajax ASP.NET MVC and ajax
ASP.NET MVC and ajax
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Asp dot net final (2)
Asp dot net   final (2)Asp dot net   final (2)
Asp dot net final (2)
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part Development
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performance
 

Viewers also liked

Encuesta De SatisfacciÓn De LogÍstica
Encuesta De SatisfacciÓn De LogÍsticaEncuesta De SatisfacciÓn De LogÍstica
Encuesta De SatisfacciÓn De LogÍsticalogisticaofficenet
 
The Window
The WindowThe Window
The WindowNafass
 
Persian New Year
Persian New YearPersian New Year
Persian New YearNafass
 
Learn to live
Learn to liveLearn to live
Learn to liveNafass
 

Viewers also liked (6)

Cozimento do Caldo
Cozimento do CaldoCozimento do Caldo
Cozimento do Caldo
 
Escaparate.
Escaparate.Escaparate.
Escaparate.
 
Encuesta De SatisfacciÓn De LogÍstica
Encuesta De SatisfacciÓn De LogÍsticaEncuesta De SatisfacciÓn De LogÍstica
Encuesta De SatisfacciÓn De LogÍstica
 
The Window
The WindowThe Window
The Window
 
Persian New Year
Persian New YearPersian New Year
Persian New Year
 
Learn to live
Learn to liveLearn to live
Learn to live
 

Similar to ASP.NET Overview - Alvin Lau

Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0py_sunil
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortalJennifer Bourey
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5Tieturi Oy
 
State management in ASP.NET
State management in ASP.NETState management in ASP.NET
State management in ASP.NETOm Vikram Thapa
 
SynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseindiappsdevelopment
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkara JUG
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen LjuSkills Matter
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen LjuSkills Matter
 
Primefaces Confess 2012
Primefaces Confess 2012Primefaces Confess 2012
Primefaces Confess 2012cagataycivici
 
Hdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed SolutionsHdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed Solutionswoutervugt
 
Simple blog wall creation on Java
Simple blog wall creation on JavaSimple blog wall creation on Java
Simple blog wall creation on JavaMax Titov
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actionsAren Zomorodian
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3masahiroookubo
 
Java Web Development with Stripes
Java Web Development with StripesJava Web Development with Stripes
Java Web Development with StripesSamuel Santos
 
Aspnet 4 new features
Aspnet 4 new featuresAspnet 4 new features
Aspnet 4 new featuresErkan BALABAN
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011Arun Gupta
 
PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014cagataycivici
 
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...SPTechCon
 
SPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking GlassSPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking GlassBrian Caauwe
 

Similar to ASP.NET Overview - Alvin Lau (20)

Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
 
State management in ASP.NET
State management in ASP.NETState management in ASP.NET
State management in ASP.NET
 
SynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseIndia dotnet client library Development
SynapseIndia dotnet client library Development
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFaces
 
JSP
JSPJSP
JSP
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Primefaces Confess 2012
Primefaces Confess 2012Primefaces Confess 2012
Primefaces Confess 2012
 
Hdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed SolutionsHdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed Solutions
 
Simple blog wall creation on Java
Simple blog wall creation on JavaSimple blog wall creation on Java
Simple blog wall creation on Java
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
 
Java Web Development with Stripes
Java Web Development with StripesJava Web Development with Stripes
Java Web Development with Stripes
 
Aspnet 4 new features
Aspnet 4 new featuresAspnet 4 new features
Aspnet 4 new features
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011
 
PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014
 
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
 
SPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking GlassSPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking Glass
 

More from Spiffy

01 server manager spiffy
01 server manager spiffy01 server manager spiffy
01 server manager spiffySpiffy
 
Active Directory Upgrade
Active Directory UpgradeActive Directory Upgrade
Active Directory UpgradeSpiffy
 
Checking the health of your active directory enviornment
Checking the health of your active directory enviornmentChecking the health of your active directory enviornment
Checking the health of your active directory enviornmentSpiffy
 
Agile in Action - Act 2: Development
Agile in Action - Act 2: DevelopmentAgile in Action - Act 2: Development
Agile in Action - Act 2: DevelopmentSpiffy
 
Agile in Action - Act 3: Testing
Agile in Action - Act 3: TestingAgile in Action - Act 3: Testing
Agile in Action - Act 3: TestingSpiffy
 
Agile in Action - Keynote: Becoming and Being Agile - What Does This Mean?
Agile in Action - Keynote: Becoming and Being Agile - What Does This Mean?Agile in Action - Keynote: Becoming and Being Agile - What Does This Mean?
Agile in Action - Keynote: Becoming and Being Agile - What Does This Mean?Spiffy
 
Agile in Action - Act 1 (Set Up, Planning, Requirements and Architecture)
Agile in Action - Act 1 (Set Up, Planning, Requirements and Architecture)Agile in Action - Act 1 (Set Up, Planning, Requirements and Architecture)
Agile in Action - Act 1 (Set Up, Planning, Requirements and Architecture)Spiffy
 
MS TechDays 2011 - WCF Web APis There's a URI for That
MS TechDays 2011 - WCF Web APis There's a URI for ThatMS TechDays 2011 - WCF Web APis There's a URI for That
MS TechDays 2011 - WCF Web APis There's a URI for ThatSpiffy
 
MS TechDays 2011 - NUI, Gooey and Louie
MS TechDays 2011 - NUI, Gooey and LouieMS TechDays 2011 - NUI, Gooey and Louie
MS TechDays 2011 - NUI, Gooey and LouieSpiffy
 
MS TechDays 2011 - Mango, Mango! Developing for Windows Phone 7
MS TechDays 2011 - Mango, Mango! Developing for Windows Phone 7MS TechDays 2011 - Mango, Mango! Developing for Windows Phone 7
MS TechDays 2011 - Mango, Mango! Developing for Windows Phone 7Spiffy
 
MS TechDays 2011 - Generate Revenue on Azure
MS TechDays 2011 - Generate Revenue on AzureMS TechDays 2011 - Generate Revenue on Azure
MS TechDays 2011 - Generate Revenue on AzureSpiffy
 
MS TechDays 2011 - HTML 5 All the Awesome Bits
MS TechDays 2011 - HTML 5 All the Awesome BitsMS TechDays 2011 - HTML 5 All the Awesome Bits
MS TechDays 2011 - HTML 5 All the Awesome BitsSpiffy
 
MS TechDays 2011 - Cloud Computing with the Windows Azure Platform
MS TechDays 2011 - Cloud Computing with the Windows Azure PlatformMS TechDays 2011 - Cloud Computing with the Windows Azure Platform
MS TechDays 2011 - Cloud Computing with the Windows Azure PlatformSpiffy
 
MS TechDays 2011 - Simplified Converged Infrastructure Solutions
MS TechDays 2011 - Simplified Converged Infrastructure SolutionsMS TechDays 2011 - Simplified Converged Infrastructure Solutions
MS TechDays 2011 - Simplified Converged Infrastructure SolutionsSpiffy
 
MS TechDays 2011 - SCDPM 2012 The New Feature of Data Protection
MS TechDays 2011 - SCDPM 2012 The New Feature of Data ProtectionMS TechDays 2011 - SCDPM 2012 The New Feature of Data Protection
MS TechDays 2011 - SCDPM 2012 The New Feature of Data ProtectionSpiffy
 
MS TechDays 2011 - Microsoft Exchange Server and Office 365 Hybrid Deployment
MS TechDays 2011 - Microsoft Exchange Server and Office 365 Hybrid DeploymentMS TechDays 2011 - Microsoft Exchange Server and Office 365 Hybrid Deployment
MS TechDays 2011 - Microsoft Exchange Server and Office 365 Hybrid DeploymentSpiffy
 
MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...
MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...
MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...Spiffy
 
MS TechDays 2011 - Cloud Management with System Center Application Controller
MS TechDays 2011 - Cloud Management with System Center Application ControllerMS TechDays 2011 - Cloud Management with System Center Application Controller
MS TechDays 2011 - Cloud Management with System Center Application ControllerSpiffy
 
MS TechDays 2011 - Virtualization Solutions to Optimize Performance
MS TechDays 2011 - Virtualization Solutions to Optimize PerformanceMS TechDays 2011 - Virtualization Solutions to Optimize Performance
MS TechDays 2011 - Virtualization Solutions to Optimize PerformanceSpiffy
 
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...Spiffy
 

More from Spiffy (20)

01 server manager spiffy
01 server manager spiffy01 server manager spiffy
01 server manager spiffy
 
Active Directory Upgrade
Active Directory UpgradeActive Directory Upgrade
Active Directory Upgrade
 
Checking the health of your active directory enviornment
Checking the health of your active directory enviornmentChecking the health of your active directory enviornment
Checking the health of your active directory enviornment
 
Agile in Action - Act 2: Development
Agile in Action - Act 2: DevelopmentAgile in Action - Act 2: Development
Agile in Action - Act 2: Development
 
Agile in Action - Act 3: Testing
Agile in Action - Act 3: TestingAgile in Action - Act 3: Testing
Agile in Action - Act 3: Testing
 
Agile in Action - Keynote: Becoming and Being Agile - What Does This Mean?
Agile in Action - Keynote: Becoming and Being Agile - What Does This Mean?Agile in Action - Keynote: Becoming and Being Agile - What Does This Mean?
Agile in Action - Keynote: Becoming and Being Agile - What Does This Mean?
 
Agile in Action - Act 1 (Set Up, Planning, Requirements and Architecture)
Agile in Action - Act 1 (Set Up, Planning, Requirements and Architecture)Agile in Action - Act 1 (Set Up, Planning, Requirements and Architecture)
Agile in Action - Act 1 (Set Up, Planning, Requirements and Architecture)
 
MS TechDays 2011 - WCF Web APis There's a URI for That
MS TechDays 2011 - WCF Web APis There's a URI for ThatMS TechDays 2011 - WCF Web APis There's a URI for That
MS TechDays 2011 - WCF Web APis There's a URI for That
 
MS TechDays 2011 - NUI, Gooey and Louie
MS TechDays 2011 - NUI, Gooey and LouieMS TechDays 2011 - NUI, Gooey and Louie
MS TechDays 2011 - NUI, Gooey and Louie
 
MS TechDays 2011 - Mango, Mango! Developing for Windows Phone 7
MS TechDays 2011 - Mango, Mango! Developing for Windows Phone 7MS TechDays 2011 - Mango, Mango! Developing for Windows Phone 7
MS TechDays 2011 - Mango, Mango! Developing for Windows Phone 7
 
MS TechDays 2011 - Generate Revenue on Azure
MS TechDays 2011 - Generate Revenue on AzureMS TechDays 2011 - Generate Revenue on Azure
MS TechDays 2011 - Generate Revenue on Azure
 
MS TechDays 2011 - HTML 5 All the Awesome Bits
MS TechDays 2011 - HTML 5 All the Awesome BitsMS TechDays 2011 - HTML 5 All the Awesome Bits
MS TechDays 2011 - HTML 5 All the Awesome Bits
 
MS TechDays 2011 - Cloud Computing with the Windows Azure Platform
MS TechDays 2011 - Cloud Computing with the Windows Azure PlatformMS TechDays 2011 - Cloud Computing with the Windows Azure Platform
MS TechDays 2011 - Cloud Computing with the Windows Azure Platform
 
MS TechDays 2011 - Simplified Converged Infrastructure Solutions
MS TechDays 2011 - Simplified Converged Infrastructure SolutionsMS TechDays 2011 - Simplified Converged Infrastructure Solutions
MS TechDays 2011 - Simplified Converged Infrastructure Solutions
 
MS TechDays 2011 - SCDPM 2012 The New Feature of Data Protection
MS TechDays 2011 - SCDPM 2012 The New Feature of Data ProtectionMS TechDays 2011 - SCDPM 2012 The New Feature of Data Protection
MS TechDays 2011 - SCDPM 2012 The New Feature of Data Protection
 
MS TechDays 2011 - Microsoft Exchange Server and Office 365 Hybrid Deployment
MS TechDays 2011 - Microsoft Exchange Server and Office 365 Hybrid DeploymentMS TechDays 2011 - Microsoft Exchange Server and Office 365 Hybrid Deployment
MS TechDays 2011 - Microsoft Exchange Server and Office 365 Hybrid Deployment
 
MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...
MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...
MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...
 
MS TechDays 2011 - Cloud Management with System Center Application Controller
MS TechDays 2011 - Cloud Management with System Center Application ControllerMS TechDays 2011 - Cloud Management with System Center Application Controller
MS TechDays 2011 - Cloud Management with System Center Application Controller
 
MS TechDays 2011 - Virtualization Solutions to Optimize Performance
MS TechDays 2011 - Virtualization Solutions to Optimize PerformanceMS TechDays 2011 - Virtualization Solutions to Optimize Performance
MS TechDays 2011 - Virtualization Solutions to Optimize Performance
 
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...
 

ASP.NET Overview - Alvin Lau

  • 1. ASP.NET 4+ Overview Alvin Lau Solutions Consultant, Datacraft MVP (ASP.NET/IIS) since Jul 2005 SGDOTNET Council Member microlau@sgdotnet.org
  • 2. ASP.NET 4+ Overview Agenda • Advancements in ASP.NET 4.0 • ASP.NET MVC 3.0 • Questions and Answers
  • 4. Advancements in ASP.NET 4.0 Overview • Core Services • Ajax • Web forms • Dynamic Data • Web Application Deployment
  • 5. Advancements in ASP.NET 4.0 Core Services <?xml version="1.0"?>  Web.config file refactoring <configuration> <system.web> <compilation targetFramework="4.0" /> </system.web> </configuration>  Extensible Output Caching <caching> <outputCache defaultProvider="AspNetInternalProvider"> <providers> <add name=“DiskCache” type="Test.OutputCacheEx.DiskOutputCacheProvider, DiskCacheProvider"/> </providers> </outputCache> </caching> <%@ OutputCache Duration="60" VaryByParam="None" providerName="DiskCache" %> public override string GetOutputCacheProviderName(HttpContext context) { if (context.Request.Path.EndsWith("Advanced.aspx"))
  • 6. Advancements in ASP.NET 4.0 Core Services  Auto-start (applicationHost.config) <applicationpools> <add name="MyApplicationPool" startMode="AlwaysRunning" /> </applicationpools> <sites> public name="MySite" id="1"> <site class CustomInitialization : System.Web.Hosting.IProcessHostPreloadClient <application path="/" { serviceAutoStartEnabled="true" public void Preload(string[] parameters) serviceAutoStartProvider="PrewarmMyCache" > { <!-- Additional content --> // Perform initialization. </application> } </site> } </sites> <!-- Additional content --> <serviceautostartproviders> <add name="PrewarmMyCache" type="MyNamespace.CustomInitialization, MyLibrary" /> </serviceautostartproviders>
  • 7. Advancements in ASP.NET 4.0 Core Services  RedirectPermanent helper (Issue HTTP 301 Moved Permanently Response)  Shrinking Session State (Using System.IO.Compression.GZipStream class) <sessionState mode="SqlServer" sqlConnectionString="data source=dbserver;Initial Catalog=aspnetstate" allowCustomSqlDatabase="true" compressionEnabled="true" />
  • 8. Advancements in ASP.NET 4.0 Core Services • Performance Monitoring (new performance counters) – % Managed Processor Time – Managed Memory Use Aspnet.config <?xml version="1.0" encoding="UTF-8" ?> <configuration> <runtime> <appDomainResourceMonitoring enabled="true"/> </runtime> </configuration>
  • 9. Advancements in ASP.NET 4.0 <%@ Page Language="C#" ... > Ajax <head runat="server">  Open-source jQuery</title> <title>Show Jquery </head> – jQuery-1.4.1.js <body> <form id="form1" runat="server"> – jQuery-1.4.1.min.js <div> – jQuery-1.4.1-vsdoc.js <asp:TextBox ID="txtFirstName"ID="sm1" EnableCdn="true" runat="server" <asp:ScriptManager runat="server" /> <script src="http://ajax.microsoft.com/ajax/jquery/jquery-  CDN Support <br /> 1.4.2.js" type="text/javascript"></script> /> <asp:TextBox ID="txtLastName" runat="server" /> </div>  Script Manager Explicit Scripts </form> <asp:ScriptManager ID="sm1" AjaxFrameworkMode="Explicit" <script src="Scripts/jquery-1.4.1.js" runat="server"> type="text/javascript"></script> <Scripts> type="text/javascript"> <script <asp:ScriptReferencefunction() { $(this).css("background-color", $("input").focus( Name="MicrosoftAjaxCore.js" /> <asp:ScriptReference Name="MicrosoftAjaxComponentModel.js" /> "yellow"); }); <asp:ScriptReference Name="MicrosoftAjaxSerialization.js" /> <asp:ScriptReference Name="MicrosoftAjaxNetwork.js" /> </script> </Scripts> </body> </asp:ScriptManager> </html>
  • 10. Advancements in ASP.NET 4.0 Web Forms  Set meta tags <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Keywords="These, are, my, keywords" Description="This is a description" %>  View State for Individual Controls  ViewStateMode (Enabled, Disabled, Inherit) <asp:PlaceHolder ID="PlaceHolder1" runat="server" <%@ Page Language="C#" AutoEventWireup="true" ViewStateMode="Disabled"> CodeBehind="Default.aspx.cs" <asp:PlaceHolder ID="PlaceHolder2" runat="server" Inherits="WebApplication1._Default" ViewStateMode="Enabled"> ViewStateMode="Disabled" %>
  • 11. Advancements in ASP.NET 4.0 Web Forms public class CustomProvider : HttpCapabilitiesEvaluator  Browser Capabilities Providers {  Replacing ASP.NET Browser Capabilities public override HttpBrowserCapabilities 1. GetBrowserCapabilities(HttpRequest request) and overrides Create provider class from HttpCapabilitiesProvider { GetBrowserCapabilities method HttpBrowserCapabilities browserCaps = 2. Register provider with application base.GetHttpBrowserCapabilities(request); – if (browserCaps.Browser == "Unknown") browserCaps section in web.config or machine.config { – Write code in Application_Start (Global.asax) browserCaps = MyBrowserCapabilitiesEvaulator(request); } Caching HttpBrowserCapabilities Object (same process) return browserCaps;  Extending ASP.NET Browser Capabilities (same process) } }
  • 12. Advancements in ASP.NET 4.0 Web Forms  Easier to useGlobal : System.Web.HttpApplication public class routing { protected void Page_Load(object sender, EventArgs e) <asp:sqldatasource id="SqlDataSource1" runat="server" {void Application_Start(object sender, EventArgs e)  PageRouteHandler class connectionstring="<%$ ConnectionStrings:MyNorthwind %>" { string searchterm = Page.RouteData.Values["searchterm"] as selectcommand="SELECT CompanyName,ShipperID FROM Shippers  New properties - HttpRequest.RequestContext, Page.RouteData string; RouteTable.Routes.MapPageRoute("SearchRoute", where label1.Text = builders - expression searchterm;  New "search/{searchterm}", "~/search.aspx"); CompanyName=@companyname" } RouteTable.Routes.MapPageRoute("UserRoute", System.Web.Compilation.RouteUrlExpressionBuilder, <selectparameters> "users/{username}", "~/users.aspx"); <asp:routeparameter name="companyname" RouteKey="searchterm" System.Web.Compilation.RouteValueExpressionBuilder http://localhost/search/scott } /> } RouteUrl  </selectparameters>  RouteValue RouteTable.Routes.Add("SearchRoute", new </asp:sqldatasource> <asp:HyperLink ID="HyperLink1" runat="server" Route("search/{searchterm}",  RouteParameter class NavigateUrl="<%$RouteUrl:SearchTerm=scott%>">Search for new PageRouteHandler("~/search.aspx"))); Scott</asp:HyperLink> http://localhost/search/scott
  • 13. Advancements in ASP.NET 4.0 Web Forms • <tc:NamingPanel runat="server" ID="ParentPanel" Setting Client IDs (ClientIDMode property) ClientIDMode="Static"> – AutoID (legacy) runat="server" ID="NamingPanel1" <tc:NamingPanel ClientIDMode="Predictable"> – Static <asp:TextBox ID="TextBox1" runat="server" – Predictable Text="Hello!"></asp:TextBox> </tc:NamingPanel> – Inherit </tc:NamingPanel> <%@ Page Language="C#" AutoEventWireup="true" <system.web> CodeFile="Default.aspx.cs" <pages clientIDMode="Predictable"></pages> Inherits="_Default" <div id="ParentPanel"> </system.web> ClientIDMode="Predictable" %> <div id="ParentPanel_NamingPanel1"> <input name="ctl00$ContentPlaceHolder1$ParentPanel$NamingPanel1$TextBox 1" type="text" value="Hello!" id="ParentPanel_NamingPanel1_TextBox1" /> </div>
  • 14. Advancements in ASP.NET 4.0 Web Forms  ASP.NET Chart Controls
  • 15. Advancements in ASP.NET 4.0 Web Forms • QueryExtender Control <asp:LinqDataSource ID="dataSource" runat="server"> TableName="Products"> ID="dataSource" runat="server"> <asp:LinqDataSource TableName="Products"> ID="dataSource" runat="server" <asp:LinqDataSource </asp:LinqDataSource> TableName="Products"> ID="dataSource" runat="server" <asp:LinqDataSource </asp:LinqDataSource> <asp:QueryExtender TargetControlID="dataSource" runat="server"> TableName="Products"> </asp:LinqDataSource> <asp:QueryExtender TargetControlID="dataSource" runat="server"> <asp:SearchExpression DataFields="ProductName, </asp:LinqDataSource> <asp:QueryExtender TargetControlID="dataSource" runat="server"> <asp:RangeExpression DataField="UnitPrice" MinType="Inclusive" Supplier.CompanyName" TargetControlID="dataSource" runat="server"> <asp:QueryExtender <asp:PropertyExpression> MaxType="Inclusive"> SearchType="StartsWith"> <asp:CustomExpression OnQuerying="FilterProducts" /> <asp:ControlParameter ControlID="CheckBoxDiscontinued" <asp:ControlParameter ControlID="TextBoxSearch" /> <asp:ControlParameter ControlID="TextBoxFrom" /> </asp:QueryExtender> Name="Discontinued" /> </asp:SearchExpression> ControlID="TexBoxTo" /> <asp:ControlParameter </asp:PropertyExpression> </asp:RangeExpression> </asp:QueryExtender> protected void FilterProducts(object sender, </asp:QueryExtender> </asp:QueryExtender> CustomExpressionEventArgs e) { e.Query = from p in e.Query.Cast() where p.UnitPrice >= 10 select p; }
  • 16. Advancements in ASP.NET 4.0 Dynamic Data  Enable on any ASP.NET application <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True" DataKeyNames="ProductID" DataSourceID="LinqDataSource1"> </asp:GridView> <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="DataClassesDataContext" EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="Products"> </asp:LinqDataSource> GridView1.EnableDynamicData (typeof(Product)); DetailsView1.EnableDynamicData(typeof(Product), new { ProductName = "DefaultName" });
  • 17. Enhancements with ASP.NET 4.0 Web App Deployment  Web Packaging Debug  Web.config transformation  Database deployment Testing Web.config Release  One-click publish for web applications Staging
  • 18. Advancements in ASP.Net 4.0 Many more… Core Dynamic Web App Ajax Web Forms Services Data Deployment Extensible Request Declarative syntax Web Packaging Validation jQuery Persisting Row Selection Range of allowable URLs Entity templates Web.config transformations Object caching CDN CSS Improvements New Field templates DB deployment Extensible HTML, URL, Creating links HTTP Header Encoding Rendering ScriptManager Improvements One-Click Publish Multi-targeting Support M:M (EF)
  • 20. ASP.NET MVC 3.0 Overview  Razor View Engine  Controller improvements  Model validation improvements  Nuget integration  Partial page output caching  Scaffolding improvements
  • 21. ASP.NET MVC 3.0 Razor View Engine  New view engine (Razor syntax)  Includes IntelliSense and color colorisation for Razor syntax  Can be unit tested  Includes HTML helpers  Chart, WebGrid, Crypto, WebImage, WebMail
  • 22. Demo – Razor View Engine
  • 23. ASP.NET MVC 3.0 Controller Improvements  Global Action Filters public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); filters.Add(new HandleLoggingAttribute()); } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); }
  • 24. ASP.NET MVC 3.0 Controller Improvements  “ViewBag” property public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; return View(); }  “ActionResult” types  HttpNotFoundResult class – HTTP 404  HttpRedirectResult class has boolean “Permanent” property – HTTP 302 or HTTP 301 public ActionResult Test(int id) { return HttpNotFound(); }
  • 25. ASP.NET MVC 3.0 Controller Improvements  JavaScript and Ajax improvements  Client-side validation enabled by default  Remote validator public class User { [Remote("UserNameAvailable", "Users")] public string UserName { get; set; } }
  • 26. Demo – Remote Validator
  • 27. ASP.NET MVC 3.0 Controller Improvements  JSON Binding support jQuery("#ajaxGrid").jqGrid({ url: '@Url.Action("GridData")', datatype: "json", jsonReader: { repeatItems: false, id: "EventId" }, colNames: ['EventId', 'EventName', 'EventDate', 'StartTime', 'EndTime', 'AllDay'], colModel: [ { name: 'EventId', editable: true, sortable: false, hidden: true }, { name: 'EventName', editable: true, sortable: false, hidden: false }, { name: 'EventDate', editable: true, sortable: false, hidden: false }, { name: 'StartTime', editable: true, sortable: false, hidden: false }, { name: 'EndTime', editable: true, sortable: false, hidden: false }, { name: 'AllDay', editable: true, sortable: false, hidden: false }, ], rowNum: 3, pager: '#ajaxGridPager', width: '850', height: '10.5em' }),
  • 28. ASP.NET MVC 3.0 Model Validation Improvements  “DataAnnotations” metadata attributes  “ValidationAttribute” Class public class User { [Required] public string Password { get; set; } [Required, Compare("Password")] public string ComparePassword { get; set; } }  Validation Interfaces  IValidatableObject, IClientValidatable interfaces  Dependency Injection Improvements
  • 29. ASP.NET MVC 3.0 Other new features  NuGet Integration  Partial-Page Output Caching [OutputCache(Duration = 3600, VaryByParam = "id")] public ViewResult Details(int id) { return View(personRepository.GetById(id)); }  Scaffolding Improvements
  • 30. Resources  Overview of ASP.NET 4 and VS 2010 Web Development http://www.asp.net/learn/whitepapers/aspnet4#0.2__Toc253429246  Unobstrusive JavaScript http://en.wikipedia.org/wiki/Unobtrusive_JavaScript  ASP.NET MVC 3 http://www.asp.net/mvc/mvc3#overview http://msdn.microsoft.com/en-us/library/gg416514(v=VS.98).aspx  ASP.NET MVC 3.0 Service Location (Dependency Injection) http://bradwilson.typepad.com/blog/2010/07/service-location-pt1-introduction.html  Steven Sanderson’s Blog about MVC Scaffolding http://blog.stevensanderson.com/category/scaffolding/
  • 31. Alvin Lau Solutions Consultant, Datacraft MVP (ASP.NET/IIS) SGDOTNET Council Member microlau@sgdotnet.org