Thursday, December 8, 2011

Communication between Cache Hosts in Windows Server AppFabric

Today I am going to talk about, how the communication/coordination takes place in between the cache host(Nodes) of Windows Server AppFabric cache cluster

In short it is achieved by using TCP/IP protocol, and as we all know If it is tcp/ip then we have to set the exception rules in our Firewall…

In order to function fully, it is going to make use of 4 different ports each with its own purpose, By default ports starts from 22233 to 22236.(so to all these we need to set the exception in firewall)…

Now we will look at what these ports will listen on…

      1)  22233 – By this port it actually communicates between the cache clients – Hence it is a cache port
      2)  22234 – By this port it ensures the availability of each other in the cluster – hence it is a cluster port
      3)  22235 – By this port it ensures that the failed nodes/host are unavailable  - Hence it is called as Arbitration port
      4)  22236 – By this port it moves the data across the hosts – hence it is called as Replication port..

If your organization doesn’t like these default ports for any reason , then you can set your own ports by using the following Windows Powershell command….

I hope this helps!.


Wednesday, December 7, 2011

Storing Session State in Windows Server AppFabric Cache


Today I am going to post about how to make use of Windows Server AppFabric Cache as Session Store for the Asp.Net Web Application.

This can be achieved by following simple steps

    1)  Add the reference of following Assembly from the following location
a.  Microsoft.ApplicationServer.Caching.Core.dll
b.   Microsoft.ApplicationServer.Caching.Client.dll
The above 2 assemblies can be located at the following locations –


    2)  Add the following entry at the ConfigSections of the Web.Config

<section name="dataCacheClient" type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
            Microsoft.ApplicationServer.Caching.Core, Version=,
            Culture=neutral, PublicKeyToken=31bf3856ad364e35"

    3)  Inside the configuration tag, add the following entry

        <host name="a4ml01382" cachePort="22233"/>
      <securityProperties mode="None" protectionLevel="None" />
      <transportProperties connectionBufferSize="131072" maxBufferPoolSize="268435456"
                         maxBufferSize="8388608" maxOutputDelay="2"  channelInitializationTimeout="60000" receiveTimeout="600000"/>


    4)  Inside the System.Web tag, add the following entry

 <sessionState mode ="Custom" compressionEnabled="true"customProvider="AppFabricCacheSessionStoreProvider" cookieless="false">
          cacheName="AspNetCacheName" />

    5)   You are all set to go from Client Asp.Net Application for making use of AppFabric cache   as Session store.. Now you need to do the following 2 steps to ensure that it works

a)  Ensure that the AppFabric Cache service is running
b)  Ensure that you have created the cache with the name – AspNetCacheName – because this is the place where in the session data is stored( We have explicitly named this ‘AspNetCacheName ‘ in step 4 )

I hope this helps!.


Tips - Windows Server AppFabric - Security Options


In this post i will be talking about the different options available while setting up the security for AppFabric cache.

Command to use setup the security..

Set-CacheClusterSecurity -SecurityMode None -ProtectionLevel None

Possible values for parameters

 SecurityMode -
     None, Transport
        A setting of Transport enables security, whereas a setting a None disables security.
ProtectionLevel  -

   Specifies the type of security applied to cache cluster data

I Hope this helps!.


Tips - Windows Server AppFabric - Grant/Revoke

Hi All,

In this post i will talk about some of the commands which you will need to use while allowing/dis-allowing the permissions for Windows Server AppFabric cache

       1)  If you need to grant any access to a particular account 

Grant-CacheAllowedClientAccount -Account "DOMAINNAME\username"

2) If you want to revoke the access to a particular account

Revoke-CacheAllowedClientAccount -Account "DOMAINNAME\username"

3) At any point in time, if you want to get the list of all accounts which are having the access to the cache, you can use - 


In next post i will talk about the different options available while settings the security to AppFabric cache

I Hope this helps!.


Tips about Windows Server AppFabric Security

A couple of days back i was trying to setup the Windows Server AppFabric. I had plenty of learning’s with this exercise and hence i thought of to share with you all.....Believe me this is an amazing powerful product from Microsoft.

Here goes the first tip...

Set-CacheClusterSecurity -SecurityMode None -ProtectionLevel None

This mode will become really handy, when you have a web application (A client to the Windows Server AppFabric) where in all the developers are trying to access the AppFabric with individual credentials.

Note: When you go live, Please ensure that you will enable the security and grant the access to the right credential/Account...

Will talk about the credentials settings in the forthcoming blogs..

I hope this helps!.


Monday, June 6, 2011

Hybrid approach of using Sync and Async actions in AsyncController

Hi All,

Today i am going to discuss about an intersting aspect or a window of opportunity which opens up when we use and AsycnController, As you might know, an AsyncController class can contain methods /actions which are of type Synchronous or Asynchronous. i.e In an AsyncController class we can have both Synchronous and Asynchronous methods.

Having said that, we also need to stick to one rule, that is if you have a Synchronous method with the name MethodCompleted – then you cant call that method since it wont be having the matching MethodAsync and if you try to call MethodCompleted without the matching MethodAsync the call will be blocked.

Inspite of all these restriction, if you still want to make use of the same ActionName – MethodCompleted – then you can have a method with some different name but decorate the action with the ActionName(“MethodCompleted”)

public ActionResult SomeMethodName()

One another note, you cant explicitly call http://localhost/MethodAsync either through an ActionLink or By using any other Redirections – we always need to do those action invoking by using http://localhost/Method

I hope this helps!.



Timeouts in Actions of AsyncController

Hi All,

Welcome back to the blog post. Today we will look at the Timeouts in action when using Async actions.

By default an action will be timed out after 45 seconds in Asp.Net mvc, If a method takes more than 45 seconds then it will throw an TimeoutException.
In order to control this behaviour Asp.Net team provide us 2 filters – [AsycnTimeout] and [NoAsyncTimeout].
If you make use of [NoAsyncTimeout] attribute to an action, then TimeoutException will never be thrown from an action.
AsyncTimeout works by taking the expiry time parameter as an input( in Milli seconds), As you know, if the action takes more than the specified time, it throws TimeoutException.

[AsyncTimeout(50000)] /* Expires after 50 seconds */
public void SampleAsync()
[NoAsyncTimeout] //Never expires
public void SampleAsync()

I hope this helps!



Usage of filters in AsyncControllers


Today i would like discuss about usage of filters in AsynControllers.

Filters such as [Authorize], [OutputCache], [ActionName] ,[AcceptVerbs] should be kept on top of ActionAsycn () method than ActionCompleted(). By mistakley if you keep the filter on top of ActionCompleted() – then it will be ignored

Now i would like to discuss one more important aspect, when we use ActionName along with the Asycn Methods. Then also we need to share the same prefix for the method name, i.e ActionAsycn and ActionCompleted.
One small twist, when we use the ActionName filte for any method, as usual the url should follow the ActionName path than the method name,
for instance,
public void SampleAsync()

public ActionResult SampleCompleted()

the request like – http://localhost//Sample – will result into Http 404.

The real path is – http://localhost/Path .

One more last thing, as you know the view name should be Path.aspx than Sample.aspx.

I hope this helps.


Friday, June 3, 2011

Choosing AsyncController vs Controller in Asp.Net mvc

Hi All,
I hope last post was really handy to those who want to implement AsyncController in Asp.Net mvc, today lets see what are all the parameters helps in deciding Synchronous and Asynchronous Controller.

1) When you have very simple method - Then prefer Controller class than AsyncController
2) When the method is more oriented towards CPU intensive task - prefer Controller class
3) When the method is more oriented towards I/O or network intensive task - prefere AsyncController class
4) When you prefer simplicity than efficiency prefere Controller class
5) When you perefer maintainability prefer Controller class.
6) When you want your request thread to be Non blocked - prefere AsyncController

I hope this helps you to make better decission duriing your design phase..


AsyncController in Asp.Net MVC

Here goes the first entry of 'About my experience with Asp.Net mvc and Windows Azure series'.
I had an requirement, where in for most of the actions, i was suppose to fetch the data from the database through WCF Services but not at the cost of blocking/reducing the throughput of mvc application....

Then i was thinking like in order to have Non blocking/high throughput - i need to make use of some asynchronous api from .Net to do the task such as either ThreadPool's QueueUserwork items , or Delegates or some asynchronous reader kind of api's....But then i surfed internet and found that there is a specific way by which this can be achieved in Asp.Net mvc......
Here are the steps by which we can get it working....

1. First create the set of WCF Services which will get the data from the database.
2. By right clicking the Asp.Net MVC project, add the service reference pointing to the wcf project.
3. During the step 2 - click on the advanced button and check 'generate asynchronous operations'
4. Inside the Asp.Net mvc project, ensure that controller class is derived from AsyncController than the default Controller class
5. For the method, Ensure that ActionName ends with 'ActionAsync' - for instance 'indexAsync'.
6. Ensure that the return type of 'ActionAsync' is void than the default ActionResult, because this method executes asynchronously.
7. Create one more method corresponding to the ActionAsync with the name - 'ActionCompleted' for instance 'indexCompleted' where in the result is returned once the action executes successfully.
8. Inside indexAsync - make a call to the wcf proxy on the asynchronous methods...for instance proxy.GetDataAsync();
9. For the callback of wcf proxy ie proxy.GetDataCompleted() - hook up the event handling by using the special class from mvc - 'AsyncManager' as shown in the following image.
10. AsyncManager's parameter class help to pass the value to the method
11. As you could see in the image, we also need to increment and decrement the async operation count - which we should be doing by using AsyncManager class.

Thats it, we achieved what we intended to.....

I hope this helps!...

If you have any queries , please do let me know..


Experience with the new technology stack from Microsoft

Hi Guys,

Please excuse me for not writing for such a long time. Was completely stuck with one of the new development project consisting of Asp.Net MVC 3.0 and Windows Azure....Now i have decided to share my experience with the latest technology stack from Microsoft( which i have used in this development assignment) tune to blog to hear more about in coming series......