Routing of URLs capability is added

Your Ad Here

Usually we use Response.Redirect method to forward a request to the new URL. However, the Redirect method issues an HTTP 302 Found (temporary redirect) response, which results in an extra HTTP round trip when users attempt to access the old URLs.

ASP.NET 4.0 adds a new RedirectPermanent helper method that makes it easy to issue HTTP 301 Moved Permanently responses, as in the following example:

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

Search engines and other user agents that recognize permanent redirects will store the new URL that is associated with the content, which eliminates the unnecessary round trip made by the browser for temporary redirects.

Subscribe
Posted in Labels: kick it on DotNetKicks.com | 1 comments

Shrinking Session State

Your Ad Here

ASP.NET provides two default options for storing session state across a Web farm:
a session-state provider that invokes an out-of-process session-state server,
a session-state provider that stores data in a Microsoft SQL Server database.
Because both options involve storing state information outside a Web application's worker process, session state has to be serialized before it is sent to remote storage. Depending on how much information a developer saves in session state, the size of the serialized data can grow quite large.

ASP.NET 4.0 introduces a new compression option for both kinds of out-of-process session-state providers. When the compressionEnabled configuration option shown in the following example is set to true, ASP.NET will compress (and decompress) serialized session state by using the .NET Framework System.IO.Compression.GZipStream class.

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

With the simple addition of the new attribute to the Web.config file, applications with spare CPU cycles on Web servers can realize substantial reductions in the size of serialized session-state data.

Subscribe
Posted in Labels: kick it on DotNetKicks.com | 1 comments

AJAX and New Template engine in ASP.NET4.0

Your Ad Here

The AJAX functionality in ASP.NET 4.0 enables new client data scenarios for page and component developers that allow JSON data from the server to be rendered as HTML in a highly manageable and efficient way. To enable these scenarios, ASP.NET 4.0 includes the following major features:

1. Client-side template rendering.
2. Declarative instantiation of client-side behaviors and controls.
3. Live data binding.
4. Use of the observer pattern with JavaScript types.
5. An AdoNetServiceProxy class for client-side interaction with ADO.NET Data Services.
6. A client-side DataView control for data-bound UI in the browser.
7. DataContext and AdoNetDataContext classes for interaction with Web services.
8. Refactored ASP.NET AJAX framework libraries.

ASP.NET 4.0 includes a new template engine for client development that meets the following requirements:

* Performance — The engine must be able to render a typical number of items using a reasonably complex template before users perceive an interruption in their interaction with the application.
* Simplicity — The template syntax must be very readable and must be optimized for the most common scenario, namely one-way/one-time binding.
* Expression language — Templates must support an expression language to go beyond the simplest cases. The expression language should use familiar syntax, ideally JavaScript syntax.
* Interspersed code and markup — It must be possible to perform conditional rendering or to loop over markup by using code that surrounds HTML.
* XHTML compliance — The template should be able to render XHTML-compliant markup.
* Components — When using the template syntax, the developer must be able to instantiate client-side controls and behaviors that attach to HTML elements in the page or within templates.

Subscribe
Posted in | 0 comments

Auto-Start Web Applications

Your Ad Here

Some Web applications need to load large amounts of data or perform expensive initialization processing before serving the first request. In earlier versions of ASP.NET, for these situations you had to devise custom approaches to "wake up" an ASP.NET application and then run initialization code during the Application_Load method in the Global.asax file.

A new scalability feature named auto-start that directly addresses this scenario is available when ASP.NET 4.0 runs on IIS 7.5 on Windows Server 2008 R2. The auto-start feature provides a controlled approach for starting up an application pool, initializing an ASP.NET application, and then accepting HTTP requests.

To use the auto-start feature, an IIS administrator sets an application pool in IIS 7.5 to be automatically started by using the following configuration in the applicationHost.config file:




Because a single application pool can contain multiple applications, you specify individual applications to be automatically started by using the following configuration in the applicationHost.config file:




preloadEnabled="true"
preloadProvider="PrewarmMyCache" >








type="MyNamespace.CustomInitialization, MyLibrary" />

When an IIS 7.5 server is cold-started or when an individual application pool is recycled, IIS 7.5 uses the information in the applicationHost.config file to determine which Web applications need to be automatically started. For each application that is marked for auto-start, IIS7.5 sends a request to ASP.NET 4.0 to start the application in a state during which the application temporarily does not accept HTTP requests. When it is in this state, ASP.NET instantiates the type defined by the preloadProvider attribute and calls into its public entry point.

You create a managed auto-start type with the necessary entry point by implementing the IProcessHostPreloadClient interface, as shown in the following example:

public class CustomInitialization : System.Web.Hosting.IProcessHostPreloadClient
{
public void Preload(string[] parameters)
{
// Perform initialization.
}
}

After your initialization code runs in the Preload method and the method returns, the ASP.NET application is ready to process requests.

For example, you can use the new auto-start feature to initialize an application and then signal a load-balancer that the application was initialized and ready to accept HTTP traffic.

Subscribe
Posted in Labels: kick it on DotNetKicks.com | 1 comments

ASP.NET 4.0 Core Services

Your Ad Here

Core Services
ASP.NET 4 introduces a number of features that improve core ASP.NET services

* output caching
* session-state storage

Extensible Output Caching
ASP.NET 4.0 allows you to configure one or more custom output-cache providers.
Output-cache providers can use any storage mechanism to persist HTML content.
like local or remote disks, cloud storage, and distributed cache engines.

You can create a custom output-cache provider as a class that derives from the new System.Web.Caching.OutputCacheProvider type.
You can then configure the provider in the web.config file by using the new providers subsection of the outputCache element, as shown in the following example:

public class CustomInitialization : System.Web.Hosting.IProcessHostPreloadClient
{
public void Preload(string[] parameters)
{
// Perform initialization.
}
}

By default in ASP.NET 4.0, all
HTTP responses,
rendered pages, and
controls
use in-memory output cache

You can also select different
output-cache providers
per
control and
per request.

You can use a providerName attribute in a page or control directive, as shown in the following example:
<%@ OutputCache Duration="60" VaryByParam="None" providerName="DiskCache" %>

Specifying a different output cache provider for an HTTP request requires a little more work. Instead of declaratively specifying the provider, you instead override the new GetOuputCacheProviderName method in the Global.asax file to programmatically specify which provider to use for a specific request. The following example shows how to do this.

public override string GetOutputCacheProviderName(HttpContext context)
{
if (context.Request.Path.EndsWith("Advanced.aspx"))
return "DiskCache";
else
return base.GetOutputCacheProviderName(context);
}

Now it is possible to cache the "Top 10" pages of a site in memory, while caching pages that get lower traffic on disk. Alternatively, you can cache every vary-by combination for a rendered page, but use a distributed cache so that the memory consumption is offloaded from front-end Web servers.

Subscribe
Posted in Labels: kick it on DotNetKicks.com | 0 comments

Whats New in ASP.NET 4.0 ?

Your Ad Here

New in ASP.NET and Visual Web Developer



The .NET Framework version 4 Beta 1 includes enhancements for ASP.NET 4 in targeted areas. Visual Studio 2010 and Microsoft Visual Web Developer Express also include enhancements and new features for improved Web development.

New Features list:

1. ASP.NET Core Services
2. ASP.NET Web Forms
3. Dynamic Data
4. AJAX Functionality in ASP.NET 4
5. Visual Web Developer Enhancements
6. Web Application Deployment with Visual Studio 2010
7. Support for MVC-Based Web Applications
8. Enhancements to ASP.NET Multi-Targeting

ASP.NET Web Forms

Following enhancements has been done in ASP.NET 4
1. The ability to set meta tags.
2. More control over view state.
3. Easier ways to work with browser capabilities.
4. Support for using ASP.NET routing with Web Forms.
5. More control over generated IDs.
6. The ability to persist selected rows in data controls.
7. More control over rendered HTML in the FormView and ListView controls.
8. Filtering support for data source controls.


Explore new features in future blogs.

Happy Coding

Subscribe
Posted in Labels: kick it on DotNetKicks.com | 0 comments

Variance in C# 4.0

Your Ad Here

Variance is of two types
1: Covariance
2: ContraVariance

It used to be that an IEnumerable/ wasn’t an IEnumerable/. Now C# allows “co-and contravariance” and common BCL types are updated to take advantage of that.
The C# compiler allows you to call a method with any name and any arguments on d because it is of type dynamic. At runtime the actual object that d refers to will be examined to determine what it means to “call M with an int” on it.
The type dynamic can be thought of as a special version of the type object, which signals that the object can be used dynamically. It is easy to opt in or out of dynamic behavior: any object can be implicitly converted to dynamic, “suspending belief” until runtime. Conversely, there is an “assignment conversion” from dynamic to any other type, which allows implicit conversion in assignment-like constructs:


dynamic d = 7; // implicit conversion
int i = d; // assignment conversion


Complete Example for variance

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LearnVarianceUse
{
class Shape { }
class Square: Shape { }

class Program
{
// Declaring delegates
delegate T Func1();
delegate void Action1(T a);

static void Main(string[] args)
{
// Creating the funcSquare function which takes no parameters , see empty ()
Func1 funcSquare = () => new Square();

// Assigning the funcSquare to funcShape type Func and it is variance which is possible only in c#4.0
// it gives compile time error in c#3.0
Func1 funcShape = funcSquare;

/*
* In the next line, we are creating a function which is called by delegate and , we
* are passing someobject which is simply printed on the console.
* */
Action1 actionShape = (objParameter) => { Console.WriteLine(objParameter); };

/* In Next line, We are assigning the actionShape Type delegate to the
* actionSquare type which was not allowed in c#3.0 but now it is possible to
* use this variance , you can use base type of delegate to inherited
* type
* */

Action1 actionSquare = actionShape;

Console.WriteLine(funcShape());
actionShape(new Shape()); // same type of object is used
actionShape(new Square()); // inherited type of object is used
Console.ReadLine();
}


}
}
if you have any queries , please email me.
Happy Coding.

Subscribe
Posted in Labels: kick it on DotNetKicks.com | 1 comments

C#4.0 New Features List

Your Ad Here

Dynamic types: is a feature which gives you a ability to skip static type checking (compile time type checking) and resolves the type at run time for the following functions.
1: Method
2: Operator
3: Indexers
4: Property
5: Field Access
6: Object Invocation

Named and optional parameters: Till now C# had no option of having optional parameters but now in C#4.0 , we can pass the optional parameters by giving them some default values like

public long addNumbers(int number1 , int number2 , long pi = 3.14){
return number1+ number2+ pi ;}

There is new option of passing the parameters by Name like
Call the above given functions as

long result = addNumbers(number2=4 , number1= 5);

Variance : In C# 3.0 , it was used to be IEnumerable and it was not allowed to be used as IEnumerable. But now in C#4.0 , co and contra-variance can be used .

In Next post, i am going to discuss the dynamic type in detail.

Till than Happpy Coding.

Subscribe
Posted in Labels: kick it on DotNetKicks.com | 1 comments

First Look VS2010

Your Ad Here

First Look of VS2010




Download Link

1:Download the VS2010

2:How to customize VS 2010

3: Brand New Extension manager for extending the VS2010

4: New Project Types


5: F# Project type and tutorial for this F# .


6: Enjoy F# programming.

Subscribe
Posted in Labels: , , , kick it on DotNetKicks.com | 2 comments