Microsoft Visual Studio 2010 and the .NET Framework 4.0 are the next generation development tools and platform for Windows Vista, the 2007 Office System, and the Web. ASPHostCentral.com as the premier Windows and ASP.NET Hosting provider has supported .NET4 Framework in all our hosting environments. The cost to host your .NET4 website/project is priced  as low as $4.99/month ONLY.

On this articles, we will present you the CORE Services that you can find on ASP.NET 4 Framework. You can certainly get this all CORE features on any hosting plans you choose.

The Core Services space has a list of new features as well including simplifying the web.config file, permanent page redirection, session state size reduction, expanding the range of allowable URLs, auto-start Web applications, and the list goes on. We’ll touch on a few here.


Auto-Start Web Applications

Some Web applications have extensive initialization code in the Application_Load method in the Global.asax file that needs to be executed before a site can process its first request. The new Auto-Start scalability featured is aimed at resolving this problem when running ASP.NET 4.0 on IIS 7.5 and Windows Server 2008 R2. Cold-starting IIS 7.5 or recycling an application pool causes IIS 7.5 to reference the applicationHost.config file to determine which applications to restart. Marking an application as auto-start informs IIS 7.5 that ASP.NET 4.0 needs to be notified to start the application.

Adding the following to the applicationHost.config file configures the TakeNoteAppPool application pool for auto-startup.


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

If your application pool contains more than a single application, you can specify which applications get auto-started with the applicationHost.config file in Listing 1. When ASP.NET is in the pre-start state, the type defined in the preloadProvider section of the applicationHost.config file has its Preload method fired.

namespace WhatsNew40
{
  
public class MyInitializationCode:
     System.Web.Hosting.IProcessHostPreloadClient
    {
        
public void Preload(string[] parameters)
        {
            
// Code to run on app start up
        }
    }
}

When the PreLoad method completes, the application is ready to process incoming requests. The new auto-start feature solves the problem of making sure your Web application is ready to accept requests before the first visitor arrives.


Shrinking Session State


Session state can be stored out of process on another server or within SQL Server. Both of these approaches require that the session state information be transmitted across the network to the receiving server. ASP.NET 4.0 introduces a way to reduce the size of that session data by compressing and uncompressing it with the System.IO.Compression.GZipStream class with the compressionEnabled setting.

<sessionState
  
mode="SqlServer"
  
sqlConnectionString="connection string here"
  
allowCustomerSqlDatabase="true"
  
compressionEnabled="true" />


Permanently Redirecting a Page

When you permanently relocate a Web page, you should return a HTTP 301 status code as well as a location header in the HTTP response of the relocated page. The HTTP 301 code will inform search engines and other user-agents that the page has permanently moved.

The new RedirectPermanent feature makes it easy to issue HTTP 301 status codes for permanently moved pages.

Response.RedirectPermanent("deadpage.aspx");


Extensible Output Caching

In its simplest forms, caching allows you to store generated HTML pages in memory. This speeds up response time when cache pages are requested since the entire page lifecycle for the page does not have to be processed. The problem with this approach is that all these items are being stored in your Web server’s memory-memory that may be at a premium for sites with heavy traffic volume

This new feature provides a way for storing those cached HTML assets in any storage mechanism you choose. A custom output cache provider is created as a class deriving from System.Web.Caching.OutputCacheProvider. A web.config entry in the new providers section of the outputCache element contains the details for your new class


Web.config Goes on a Diet

With all the features that have been added to ASP.NET over the years, it was inevitable that the web.config would swell in size. Add in the new features in ASP.NET 4.0 such as routing, AJAX, outputCaching Providers and so on, and the swelling continues. New to ASP.NET 4.0 is the moving of major configuration settings into the machine.config file with applications inheriting these settings.

This allows an application to simply not have a web.config file or to have a very simple one like this one specifying the framework version being targeted.


Listing 1: applicationHost.config file settings for Auto-Start

<sites>
  
<site name="MainSite" id="1">
    
<application path="/"
       
preloadEnabled="true"
       
preloadProvider="AutoLoadData" >
       
<!--  //Additional application settings here// -->
    
</application>
  
</site>
</sites>

  
<!-- //Additional settings here// -->

<preloadProviders>
   
<add name="AutoLoadData "
        
type="WhatsNew40.MyInitialzationCode, WhatsNew40" />
</preloadProviders>