Introduction to. NET 4.0 Improvements

Source: Internet
Author: User
Tags config iis sql new features client
Most of the new features are built around customizations and extensions, things that were previously not customizable can now be customized, can be extended by themselves, and then configured with their own components in Web.config to apply our own components.

Web.config streamlining

. NET Framework 4.0 will put most of the configuration in the Machine.config, so that in the web.config can not even write a line of code.

Customizing the output Caching policy

Output caching is good for performance, and it is possible to customize output caching policies in ASP.net 4.0, such as saving output to disk, external memcached services, and so on. You can even define advanced rules, such as using a output caching policy for page A to keep data in memory, and use B-output caching policies for B pages to save data to disk.

<caching>

<outputcachedefaultprovider= "Aspnetinternalprovider" >

<providers>

<addname= "DiskCache"

Type= "Test.OutputCacheEx.DiskOutputCacheProvider, Diskcacheprovider"/>

</providers>

</outputCache>

</caching>

Self-initiated applications

asp.net 4.0 and IIS 7.5 can be configured with a preprocessed provider so that IIS automatically calls the code in this provider after the application pool is started or reclaimed, and then accepts the request after processing.

<preloadProviders>

<addname= "Prewarmmycache"

Type= "mynamespace.custominitialization, mylibrary"/>

</preloadProviders>

Permanent redirect

If you use Response.Redirect, the 302 state is returned, the client sends another request to the new address, and the Redirectpermanent method is provided in ASP.net 4.0 to permanently redirect to an address. The client or search engine encounters a 301 status code that saves the permanent redirect address and then directly accesses the redirected address, saving a round-trip.

Compress session Data

If session data needs to be serialized and deserialized using out-of-process sessions or SQL Server, ASP.net 4.0 provides an attribute that uses Gzip to compress session data to reduce the size of the session data stream.

<sessionstate

mode= "SQL Server"

sqlconnectionstring= "Data source=dbserver;initial catalog=aspnetstate"

Allowcustomsqldatabase= "true"

Compressionenabled= "true"

/>

URL Rules

In asp.net 4.0 you can customize the access path and the length of the querystring, and you can also set invalid characters in the path that were not previously customizable.

Custom Requestvaidation

Although requestvalidateion can effectively prevent XSS injection and so on, but in the past validation rules can not be customized, many times we feel that this rule is too strict to only turn off this feature. In ASP.net 4.0, you can customize the class to implement your own validation rules.


Object caching

System.Web.Caching.Cache Everyone is familiar with, and sometimes even write Windows and Windows service programs will also refer to System.Web.dll to use this cache function. In 4.0, this feature will have a new implementation in System.Runtime.Caching.dll and will be more powerful.

Custom encoding

URL encoding/html Encoding are commonly used functions, in ASP.net 4.0 we can inherit System.Web.Util.HttpEncoder from the definition of encoding rules.

Performance detection at the AppDomain level

If you run multiple sites in a process, we may want to monitor the performance of each site, and in ASP.net 4.0 we can turn on AppDomain level performance testing.

<?xml version= "1.0" encoding= "UTF-8"?>

<configuration>

<runtime>

<appdomainresourcemonitoring enabled= "true"/>

</runtime>

</configuration>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.