ASP.NET 4.0 and VS 2010 Web Development

Report
ASP.NET 4.0 AND
VS 2010 WEB DEVELOPMENT
BETA 1
VTALKS #12 @Microsoft Thailand All Season Place
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
this.MetaKeywords = "Greatfriends.biz, Visual Studio 2010, .NET, ASP.NET 4.0,
SilverLight, Team System 2010";
this.MetaDescription = "VTALKS #12“;
 Demo
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
New Browser Definition Files:
 blackberry.browser
 iemobile.browser
 chrome.browser
 iphone.browser
 Default.browser
 opera.browser
 firefox.browser
 safari.browser
 gateway.browser
 generic.browser
 ie.browser
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 [email protected]“
<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
Namespace System.Caching
{
Disk
based
Inmemory
Cache
Windows
Azure
CacheProvider
Distributed
}
New 4.0 Output Cache
Functionality
Namespace System.Web.Caching
{
Disk
based
Inmemory
Default.aspx
Foo.ascx
Windows
Azure
OutputCacheProvider
Distributed
}
Extensible Output Caching
 Add Output Cache Provider in web.config
<caching>
<outputCache defaultProvider="AspNetInternalProvider">
<providers>
<add name="DiskCache" type="Test.OutputCacheEx.DiskOutputCacheProvider, DiskCacheProvider" />
</providers>
</outputCache>
</caching>
 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)
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>
Auto-Start Web Applications
 specify individual applications pool to be
automatically started
<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.IProcessHostPreloadClie
nt
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
<httpRuntime maxRequestPathLength="260" maxQueryStringLength="2048" />
 Customize request path validator
<httpRuntime requestPathInvalidChars="<,>,*,%,&,:,\" />
Extensible Request Validation
 Prevent Cross-site scripting (XSS) attacks
 Validate Process on HttpRuntime, add tag in
web.config
<httpRuntime requestValidationType="Samples.MyValidator, Samples" />
 Customizable with your code
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
Web Application Deployment
with Visual Studio 2010
 Web packaging
 10 + 20 reasons why you should create a Web
Package
 Web.config Transformation
 Web Deployment: Web.Config Transformation
 Database deployment
 Database Deployment with VS 2010
 One-Click Publish for Web applications
 Web 1-Click Publish with VS 2010
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/aspnet40
 http://weblogs.asp.net/scottgu

similar documents