Archive for the ‘SQL and .NET Blog’ Category

Design concepts MANTRA – Always keep handy

March 25, 2015 Leave a comment

There are several design principles which are around us. All focussing on these key principles.

1. Separation of Concerns: Don’t overlap your functionality and keep the functions in distinct chunks

2. Single Responsibility Principle: Each component should be responsible for handling a single feature.

3. Principle of Least Knowledge (Law of Demeter – LoD): A component should not know about the internal details of other components.

4. Don’t repeat Yourself (DRY): The functionality or logic should not be repeated in any other component.

5. Minimise Upfront Design: Only design for what is necessary and don’t exaggerate the services and over design the concepts. This might lead to complexity and excess cost.


Architectural Styles – A consolidated view

1. Client/Server:  Segregates the system into two applications, where the client makes requests to the server.
2. Component-Based Architecture: Decomposes application design into reusable functional or logical components that expose well-defined communication interfaces.
3. Domain Driven: Design An object-oriented architectural style focused on modeling a business domain
and defining business objects based on entities within the business domain.
4. Layered Architecture: Partitions the concerns of the application into stacked groups (layers).
5. Message Bus: An architecture style that prescribes use of a software system that can receive and send messages using one or more communication channels, so that applications can interact without needing to know specific details about each other.
6. N-Tier / 3-Tier: Segregates functionality into separate segments in much the same way as the layered style, but with each segment being a tier located on a physically separate computer.
7. Object-Oriented: A design paradigm based on division of responsibilities for an application or system into individual reusable and self-sufficient objects, each containing the data and the behaviour relevant to the object.
8. Service-Oriented Architecture (SOA): Refers to applications that expose and consume functionality as a service using contracts and messages.



Categories: Architecture

CSRR – Change Save Refresh Result – in ASP.NET 5.0

March 25, 2015 Leave a comment

There is one step leap in .NET framework.

This new outburst of change-save-refresh-result (CSRR) will change the way the developers tie code.

Dynamite Scott has introduced this dynamic feature to our community.





Categories: SQL and .NET Blog

HTTP errors in IIS 7.0

November 4, 2010 Leave a comment

Have you installed fresh IIS 7.0 into the server??

Yes, probably you could face this error at first time…


HTTP Error 404.17 – Not Found

The requested content appears to be script and will not be served by the static file handler.




This is because installation was not registered correctly. Try the following steps to register it.

run %windir%\Microsoft.NET\Framework\v4.0.21006\aspnet_regiis.exe –i

And the next possible error very often at first time is


HTTP Error 404.17 – Not Found

The requested content appears to be script and will not be served by the static file handler.



This is because you have not enabled the permission for ISAPI and CGI restrictions

Just do the following steps and this will help

# Install the feature that handles this request. For example, if you get this error for an .ASPX page, you may have to install ASP.NET via IIS setup.
# Verify that the Web service extension requested is enabled on the server.

   1. Open the IIS Manager and navigate to the server level.
   2. In the Features view, double-click ISAPI and CGI Restrictions to verify that the Web service extension is set to Allowed.
   3. If the extension is not in the list, click Add in the Actions pane.
   4. In the Add ISAPI and CGI Restrictions dialog box, type the path of the .dll or .exe file in the ISAPI or CGI Path box, or click Browse to navigate to the location of the file.
   5. In the Description box, type a brief description of the restriction.
   6. (Optional) Check "Allow extension path to execute" to allow the restriction to run automatically. If you do not check this option, the restriction status is Not Allowed, which is the default. You can allow the restriction later by selecting it and clicking Allow on the Actions pane.
   7. Click OK.


Explore IIS with freedom..


Categories: SQL and .NET Blog

What happens in IIS?

November 4, 2010 Leave a comment


Wanna know in depth on how request and response are processed: go to this link..


IIS (Internet Information Server) is one of the most powerful web servers from Microsoft that is used to host your ASP.NET Web application. IIS has it’s own ASP.NET Process Engine  to handle the ASP.NET request. So, when a request comes from client to server, IIS takes that request and  process it and send response back to clients.


When client request for some information from a web server, request first reaches to HTTP.SYS of IIS. HTTP.SYS then send the request to respective  Application Pool. Application Pool then forward the request to worker process to load the ISAPI Extension which will create an HTTPRuntime Object to Process the request via HTTPModule and HTTPHanlder. After that the ASP.NET Page LifeCycle events starts.


Worker process(w3wp.exe) runs the web application in the web server.

Application pool is the container of the worker process.




HTTP.SYS is Responsible for pass the request to particular Application pool. Whenever we creates a new Application Pool, the ID of the Application Pool is being generated and it’s registered with the HTTP.SYS. So whenever HTTP.SYS Received the request from any web application, it checks for the Application Pool and based on the application pool it send the request.

Now the control request from the remote user moves from http.sys to the application pool and then to the worker process as discussed.



This is just the basic understanding and the birds eye view of the request processing in IIS.


Categories: SQL and .NET Blog

Web-Farm and Web-Garden

October 3, 2010 2 comments

© from


I have been asked this question many times by different readers of my blog. They wanted to know about the fundamentals of Web Farms and Web Garden . In this blog post  I am going to explain the what is the exact difference between web farm and web garden, what are the advantages and disadvantages of using them. I have also described how to create web garden in different version of IIS.

Overview :

Visual Studio having its own integrated ASP.NET engine which is used to run the ASP.NET Web application from Visual Studio. ASP.NET Development Server  is responsible for execute all the request and response from client. Now after the end of development, when you want to host the site on some server to allow other peoples to access, concept of web servers comes in between.  A web server is responsible for  provide the response for all the requests that are coming from clients. Below diagram showing the typical deployment structure of a ASP.NET Web application with a single IIS.

Clients request for resources and IIS Process the request and send back to clients. If you want to know more details on How IIS Process the request please read one of my article over “How IIS Process ASP.NET Request ?” .

Web Farm :

This is the case, where you have only one web server and multiple clients requesting for the resources from the same server. But when there is huge numbers of  incoming traffic for your web sites, one standalone server is not sufficient to process the request.  You may need to use multiple server to host the application and divide the traffic among them.  This is called “Web Farm” . So when you are hosting your single web site on multiple web server over load balancer called “Web Farm”. Below diagram showing the over all representation of Web Farms.

In general web farm architecture, a single application is hosted on multiple IIS Server and those are connected with the VIP ( Virtual IP ) with Load Balancer. Load Balancer IP’s exposed to external worlds to access. So whenever some request will come to server from clients, it will first hit the Load Balancer, then based on the traffic on each server LB distributed the request to corresponding web server.  These web server may share same DB server or may be they can use replicated server in the back end.

So, In a single statement, When we host a web application over multiple web server to distributed the load among them  is called Web Farm.

Web Garden :

Now, let’s have a look, what is Web Garden ?  Both the terms  sounds same,  but they are totally different with each other.  Before starting with Web Garden, I hope you have fundamental idea of what is Application Pool and what is Worker Process.  If you have already read the article  “How IIS Process ASP.NET Request ?” article then I can expect that you have now good idea on both of them.

Just to recall,  When we are talking about requesting processing with in IIS, Worker Process (w3wp.exe ) takes care all of these. Worker Process runs the ASP.Net application in IIS. All the ASP.Net functionality inside IIS  runs under the scope of worker process. Worker Process is responsible for handling all kind of request, response, session data, cache data.  Application Pool is the container of worker process. Application pools is used to separate sets of IIS worker processes and enables a better security, reliability, and availability for any web application.

Now, by default each and every Application pool contains a single worker process. Application which contains the multiple worker process called “Web Garden”. Below is the typical diagram for a web garden application.

In the above diagram you can see, on of the application containing the  multiple worker process, which is now a web garden.

So, a Web application hosted on multiple server and access based on the load on servers is called Web Farms and When a single Application pool contain multiple Worker process is called web garden.

Create Web Garden in IIS 6 and IIS 7

Now, I am going to show how you can change the Number of Worker process In both IIS 6 and IIS 7.  For IIS 6,  Right Click on Application Pool > Properties > Goto  Performance Tab.

In the “Performance Tab” Section you would have one option called “Web Garden” where worker process sets to “1”, you can set the number of worker process that you required.

For IIS 7, Right Click on Application Pool > Go To Advance Settings > In Process Model section, you will have “Maximum Worker Processes” . You can change it more than 1 to make it as web garden.

In the above image you can also check the definition of Web Garden also.

You can find one of my previous article on the basic of same over here

Advantages of Web Farm and Web Garden :

Now, let’s have a look in to the advantages of both the Web farms and Web Garden.

Advantages of Web Farm

  • It provides high availability. If any of the server in the farm goes down, Load balancer can redirects the requests to other servers.
  • Provides high performance response for client requests.
  • Provides Better scalability of the web application and reduce the failure of application.
  • Session and other resource can be stored in a centralized location to access by the all server.

Advantages of Web Garden:

  • provides better application availability by sharing request between multiple worker process.
  • Web garden use processor affinity where application can swapped out based on preference and tag setting.
  • Less consumption of physical space for web garden configuration.

How to manage session in Web Farm Mode ?

While using session, requests are distributed among different servers. By default session mode is set to In Proc where session data stored inside worker process memory. But, In Web farm mode we can share the session among all the server using a single session store location my making it Out proc (State Server or SQL Server Mode). So, if some of the server goes down and request transferred to the other server by the Load balancer session data should be available for that request.

In the above diagram,  you can see we can both the IIS server sharing the same session data which is stored in out of worker process.  You can read one of my previous article “Exploring Session in ASP.NET” where I have explained how you can configure session mode for Out Process mode.

How to manage session in Web Garden Mode ?

When we are using Web garden where request is being taking care by different worker process we have to make the session mode as out process session mode as described earlier. For Web Garden we have configure the out process with in same server but for different worker process.

While using Web garden with your application you need do couple of configuration settings in web.config in <process Model> section where you need to set certain properties like cpuMask, RequestLimit, webGarden, ClientConnectCheck etc.

Summary : When we host a web application over multiple web server to distributed the load among them  is called Web Farm and when One application having multiple worker worker process called Web garden.



Yield keyword in C# – Reduces LOC

September 30, 2010 Leave a comment

Yield keyword is employed to reduce the allocation of arrays and by using a simple foreach iterative control structure.

Here’s a simple program which displays the first five even numbers.


   1: private void LearnYield_Click(object sender, EventArgs e)
   2:        {
   3:            // this is the main program
   4:            string result = String.Empty;
   6:            foreach (int value in ShowEvenNum(2, 5))
   7:            {
   8:                result = result + " - " + value.ToString();
   9:            }
  11:            MessageBox.Show(result);
  12:        }
  14:        // this method returns the list of first five even numbers
  15:        public static IEnumerable<int> ShowEvenNum(int number, int multiplier)
  16:        {
  17:            int loopValue = 0;
  18:            int numberResult = 0;
  20:            while (loopValue < multiplier)
  21:            {
  22:                numberResult += number;
  23:                loopValue++;
  25:                // this yield keyword will directly add to the return list
  26:                yield return numberResult;
  27:            }
  29:        }

This code and its comments are self explanatory.


SCSF for Visual Studio 2008 SP1

September 11, 2010 Leave a comment

This is regarding the installation of SCSF for Visual studio 2008 SP1.

Here you can see lot of issues for the release of SP1 with SCSF

Yes, The fix is also available for this.

Downoad the solution from the link below

"Download here"

1. Open and build the GuidancePackage.sln solution to generate the installer.
2. Navigate to the SmartClientFactorySetup\Debug folder.
3. Close all instances of Visual Studio.
4. Run the SmartClientFactoryPackageSetup.msi installer.

And now open the VS 2008 instance and check for the new project and you will see the image as below.

Click on the newer version and enjoy coding.


Silverlight Developer runtime error

July 4, 2010 Leave a comment

Yup, Silverlight developer runtime has to be installed in any development environment for the debugging and execution of the silverlight applications.

You may face errors like "Silverlight Developer Runtime is not installed"

This is due to runtime not available in your local development system.

To install the runtime exe, download this from here:

And try executing the application again and everything will work fine…

Happy coding !!!


Categories: SQL and .NET Blog

Optional (or Default) Parameters in C# 4.0


This feature of C# has been obtained from VB.NET. In new C# 4.0 there is an option to pass all the parameters as optional and no need to unnecessarily overload the methods. This is really a great feature to be implemented in all the programming languages.

Hands on:

Prior to that we have to include the using of

using System.Runtime.InteropServices

And our functionality as follows

public void MainMethod()
       int parameter1 = 1;
       int parameter2 = 2;
       MethodCall2(parameter1,parameter2);     // This method will call MethodCall2 as usual
       MethodCall2(parameter1);                // This method will call MethodCall2 with only 1 parameter and the other is Optional
   public void MethodCall1(int x)
       // this is an example of ordinary method execution
       Console.WriteLine("MethodCall1 is executed");
   public void MethodCall2(int x, [Optional] int y)
       // This method will be called with 1 parameter and also with 2 parameters
       Console.WriteLine("MethodCall2 is executed");


Categories: SQL and .NET Blog

Enterprise Library 3.1 – error while installing – Error code 2869

April 15, 2010 5 comments

Yup, there could be errors like the below image while installing “Enterprise Library May 2007.msi”.

The reason I found for this is, this enterprise library version checks for Visual studio 2005 is installed in the system, though Visual studio 2008 is installed.

I have just installed VS 2008 in my system and thus facing the same error.


1. Install Visual Studio 2005 and then install this “Enterprise Library May 2007.msi”.   –>> Don’t waste time doing this.

2. Download latest Enterprise library like 5.0 or 5.0 beta2 from codeplex  –>>

The latest version of Enterprise library will install perfectly with out any installation errors.

Happy coding…


Categories: SQL and .NET Blog