VTALKS #12 @Microsoft Thailand All Season Place. Agenda Web Forms Core Services Web Designer...

36
ASP.NET 4.0 AND VS 2010 WEB DEVELOPMENT BETA 1 VTALKS #12 @Microsoft Thailand All Season Place Chalermpon Areepong : Nine (นนน) Microsoft MVP Thailand Greatfriends.biz Community Lead
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    215
  • download

    0

Transcript of VTALKS #12 @Microsoft Thailand All Season Place. Agenda Web Forms Core Services Web Designer...

ASP.NET 4.0 ANDVS 2010 WEB DEVELOPMENT BETA 1VTALKS #12 @Microsoft Thailand All Season Place

Chalermpon Areepong : Nine (นาย)Microsoft MVP Thailand

Greatfriends.biz Community Lead

Agenda

Web Forms Core Services Web Designer Improvement Web Application Deployment Dynamic Data AJAX Functionality in ASP.NET 4.0

ASP.NET 4.0 Web Forms Feature

Set meta tags on Web Forms Feature for Search Engine Optimize

(SEO) Allow set page meta tags

keywords description

With Coding

Demo

this.MetaKeywords = "Greatfriends.biz, Visual Studio 2010, .NET, ASP.NET 4.0, SilverLight, Team System 2010";this.MetaDescription = "VTALKS #12“;

View State for Individual Controls ViewStateMode tag

Enabled (default value) Disabled Inherit

Able to specify for each control Able to force all control at Page

Directive Demo

Browser Capabilities

Using determines browser that user is using browse to you site.

To get user browser information HTML, XHTML support version JavaScript version Mobile Browser

HttpBrowserCapabilities object after using this feature.

Browser Capabilities

blackberry.browser chrome.browser Default.browser firefox.browser gateway.browser generic.browser ie.browser

iemobile.browser iphone.browser opera.browser safari.browser

New Browser Definition Files:

Using Browser Capabilities Providers Using ASP.NET Standard Browser

Capabilities Use aspnet_regbrowsers.exe –i , It’s will create

ASP.BrowserCapsFactory.dll and install to GAC Restart IIS iisreset

Custom your Browser Capabilities Derived HttpCapabilitiesProvider Class Override GetBrowserCapabilities Method to

return your BC. Register to web.config <browserCaps … Use in Global.asax Application_Start() Event

Browser Capabilities Providers HttpBrowserCapabilities object

caching Extending ASP.NET Browser

Capabilities Functionality Extending Browser Capabilities

Functionality by Adding New Capabilities to Existing Capabilities Definitions

ASP.NET Web Forms Routing

Let you configure new simple URL SEO Optimize It Likes ASP.NET MVC Routing

Such as from http://website/products.aspx?categoryid=

12 To new URL

http://website/products/software

ASP.NET Web Forms Routing

Map routing in Global.asax file on Application_Start() Event, Add RouteTable.Routes.MapPageRoute() method

checkPhysicalUrlAccess for restrict URL access permission

Reading Routing Information in a Web Forms Page Page.RouteData.Values["searchterm"] as string; value “http://localhost/search/scott/”

ASP.NET Web Forms Routing

Accessing Routing Information in Markup <asp:HyperLink ID="HyperLink1" runat="server“ NavigateUrl="<%

$RouteUrl:SearchTerm=scott%>">Search for Scott</asp:HyperLink> value “http://localhost/search/scott/”

Using Route Data for Data Source Control Parameters RouteParameter class lets you specify route data as a

parameter value for queries in a data source control. It works much like FormParameter <asp:sqldatasource id="SqlDataSource1" runat="server“

connectionstring="<%$ ConnectionStrings:MyNorthwind %>” selectcommand="SELECT CompanyName,ShipperID FROM Shippers where CompanyName=@companyname“ <selectparameters><asp:routeparameter name="companyname" RouteKey="searchterm" /></selectparameters></asp:sqldatasource>

ASP.NET 4.0 Client ID

Control ID Feature ClientIDMode

AutoID – Auto Generate by ASP.NET. Static – Fix ID Predictable – For repeating template

control, in ClientIDRowSuffix should be PrimaryKey or Object ID

Inherit –default behavior, same as its parent.

Persisting Row Selection in Data Controls Persist Selected Row Enabled for GridView and ListView

controls Use EnablePersistedSelection

<asp:GridView id="GridView2" runat="server" EnablePersistedSelection="true"> </asp:GridView>

ASP.NET 4.0 Core Services Feature

Web.config File Minification Move major configuration to

machine.config, and leave your new configuration only

Able to override value on web.config<?xml version="1.0"?> <configuration> <system.web> <compilation targetFramework="4.0" /> </system.web> </configuration>

Extensible Output Caching

Session State SQL Server State Output Cache Providers (New)

Allow your set default cache provider Able to customize your output cache

provider Able to configure one or more

New 4.0 Cache Functionality

Cache

Namespace System.Caching{

}

CacheProvider

Disk based

Windows Azure

Distributed

In-memory

New 4.0 Output Cache FunctionalityNamespace System.Web.Caching{

}

Disk based

Windows Azure

Distributed

In-memory

OutputCacheProvider

Default.aspx

Foo.ascx

Extensible Output Caching Add Output Cache Provider in

web.config

Can specify page to use output cache provider with Page and Control Directive <%@ OutputCache Duration="60" VaryByParam="None"

providerName="DiskCache" %>

Configure all in Global.asax public override string GetOutputCacheProviderName(HttpContext context)

<caching> <outputCache defaultProvider="AspNetInternalProvider"> <providers> <add name="DiskCache" type="Test.OutputCacheEx.DiskOutputCacheProvider, DiskCacheProvider" /> </providers> </outputCache> </caching>

Auto-Start Web Applications Many web app need to load initialize

data. This expensive to do Solve the first requests Timeout

problem Wake up asp.net app with your

custom code on Application_Load Event in Global.asax file

For ASP.NET 4.0 + IIS 7.5 + Win2K8 R2 Only

Config in %Windows%\System32\inetsrv\config applicationHost.config

<applicationPools> <add name="MyApplicationPool" startMode="AlwaysRunning" /></applicationPools>

specify individual applications pool to be automatically started

Auto-Start Web Applications

<sites> <site name="MySite" id="1"> <application path="/“ preloadEnabled="true“ preloadProvider="PrewarmMyCache" > <!-- Additional content --> </application> </site></sites> <!-- Additional content  <preloadProviders> <add name="PrewarmMyCache" type="MyNamespace.CustomInitialization, MyLibrary" /></preloadProviders>

Auto-Start Web Applications For implement PreloadProvider

using System.Web.Hosting.IProcessHostPreloadClient public class CustomInitialization : System.Web.Hosting.IProcessHostPreloadClient

{ public void Preload(string[] parameters) { // Perform initialization. }}

Permanently Redirecting a Page Feature for Search Engine Optimize

(SEO) Generate Http 301 on response

header and attached new URL of request page

Just call this method Response.

RedirectPermanent("/newpath/foroldcontent.aspx");

The Incredible Shrinking Session State Support both out-of-process and

session-state providers Just configure in web.config

<sessionState mode="SqlServer" sqlConnectionString="data source=dbserver;Initial Catalog=aspnetstate" allowCustomSqlDatabase="true" compressionEnabled="true" />

Expanding the Range of Allowable URLs Expand URL range from 260

characters (old asp.net) to customize value

Customize request path validator

<httpRuntime maxRequestPathLength="260" maxQueryStringLength="2048" />

<httpRuntime requestPathInvalidChars="<,>,*,%,&,:,\" />

Extensible Request Validation Prevent Cross-site scripting (XSS)

attacks Validate Process on HttpRuntime,

add tag in web.config

Customizable with your code

<httpRuntime requestValidationType="Samples.MyValidator, Samples" />

public class CustomRequestValidation : RequestValidator { protected override bool

IsValidRequestString( HttpContext context, string value, RequestValidationSource requestValidationSource, string collectionKey, out int validationFailureIndex)

{ ... } }

Object Caching and Object Caching Extensibility New MemoryCache class in

System.Runtime.Caching.dll Allow call from any Application Type

without System.Web.dll dependency For do this required documentation

for implement, Please wait!

Extensible HTML, URL, and HTTP Header Encoding System.Web.Util.HttpEncoder

Extensible to create Custom Encoding on HttpRuntime

Add custom encoding in web.config file

<httpRuntime encoderType="Samples.MyCustomEncoder, Samples" />

Performance Monitoring for Individual Applications in a Single Worker Process Diagnostic worker process feature by

CRL Admin can configure in aspnet.config

file<?xml version="1.0" encoding="UTF-8" ?> <configuration> <runtime> <appDomainResourceMonitoring enabled="true"/> </runtime> </configuration>

Multi-Targeting

Allow to specify version of .NET framework<Codedom>

<compilation targetFramework="4.0"/> …..

ASP.NET 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. Smart data labels that can automatically fit around data

points. Strip lines, scale breaks, and logarithmic scaling. More than 50 financial and statistical formulas for data

analysis and transformation. Simple binding and manipulation of chart data. Support for common data formats, such as dates, times, and

currency. Support for interactivity and event-driven customization,

including client click events using AJAX. State management. Binary streaming.

ASP.NET Chart Control

Visual Studio 2010 Web Designer Improvements Improved CSS Compatibility using

CSS 2.1 HTML and JScript Snippets JScript IntelliSense

Enhancements

Resource

Visual Studio 2010 Beta 1 http://go.microsoft.com/?linkid=9666892

ASP.NET 4.0 Beta 2 Documentation http://www.asp.net/learn/whitepapers/as

pnet40

http://weblogs.asp.net/scottgu