Software Architecture – Web Application optimization without code changes

November 11, 2011

Objective: Web Application optimization without code changes.
Strategy: Read all the references below and apply them in test lab. After clear understanding of domain, have access to Client machine and apply this checklist on client machine. Make sure to have backup strategy for client environment.
Guideline Points:
1. Log only essential information or completely disable IIS logging
2. Disable IIS ASP debugging in production environments
3. Tune the value of the ASP Threads Per Processor Limit property
4. Tune the value of the ASP Queue Length property
5. Tune the MaxPoolThreads registry entry
6. Disable WCF services tracing
7. Configure ASP.NET MaxConcurrentRequests for IIS 7.0 Integrated mode
8. Enable IIS HTTP compression
For point 1-8 see below reference)
(Reference: )

9. Configuring HTTP Compression in IIS 7
(Reference: )

10. Configuring Output Caching in IIS 7
(Reference: )

11. Follow this link:

12. For web Pages add following tag.


13. Optimizing WCF Web Service Performance

14. Few tips related to ASP .Net

15. Few tips related to ASP .Net

16. For better performance, you should remove any HTTP Modules that you are not using.

17. Performance Tuning for Active Directory Servers (Important)
[In this white paper, read Active Directory section.]

18. AD performance Tuning

Software Architecture-Strategy for Performance tuning a .Net application

September 10, 2011

Strategy for Performance tuning a .Net application:
There are two parts to work in terms of performance tuning.
First part, is application specific optimization which refer to things required in terms of product under development. It requires deep product knowledge and code level awareness of product.
Second part, is technology specific optimization which refer to things provide by technology as tip to improve the performance.
For second part, following is list of acts to be taken.

1. Allocate a senior resource to act as PIG in SCRUM theory for this task.
2. Analyze the technologies used in application like c#, .Net, ASP .Net, WCF, MVC, IIS. Identify set of checklist which needs attention to be verified in application.
3. First step would be to review code in application. Second step would be to apply the checklist identified in step 2.
4. Bench mark the effect of each change in application (checklist) to analyze the performance.
5. QA team member can really help in it.

Online References for implementing checklist:

C# Performance:



ASP .Net Performance:

WCF Performance:


MVC Performance:

Software Architecture-Page Methods of ASP .Net/AjAX with DataTable control-Yahoo UI library

February 16, 2011

Objective:To use Page Methods of ASP .Net/AjAX with Yahoo UI library.

There are three approaches to Programming in ASP.NET AJAX.
1. UpdatePanel: Contains a group of server controls and monitors their postbacks and rendering process. Any requests for postback that originate from the contained controls are hijacked and served via script. Changes to the page are applied using DHTML.
2. Remote method calls: Blanket term for asynchronous calls to page methods and local and external Web services. Calls move input arguments and receive return values via JSON streams in a type-independent manner. Strongly typed JavaScript code is required to trigger the call and apply changes back on the client.
3. Client-side data binding: Two client-side controls written entirely in AJAX JavaScript to implement template-based binding. They are ListView, for multiple-records view, and ItemView, for single-record view. These two controls are combined together with client data source and filtering components.
In this Post, we will use Page Methods with Yahoo UI Library.
Page Method is a public static method defined in the codebehind class and decorated with the same WebMethod attribute used for Web service methods.
Yahoo UI Lib is really power full client side UI library.
For details about it, please visit at: details about DataTable control, visit:
DataTable control major features includes sortable columns, pagination, scrolling, row selection, resizeable columns, and inline cell editing.
1. Consider a entity class for showing History Items:

// Sample Object to be returned to client end via Page Method.
    public class HistoryItem{
        public Int32 ID { get; set; }
        public String Name { get; set;}
        public String Desc { get; set; }
        public DateTime Date { get; set;}

2. Define a Page Method as below:

/// <summary>
        ///  Page Method for client side data return
        /// </summary>
        /// <returns> List of HistoryItem object to be returned... </returns>
        public static List<HistoryItem> GetPageMethod()
            // Prepare Sample Data
            List<HistoryItem> lst = new List<HistoryItem>
                        new HistoryItem { ID = 1, Name = "Created 1" , Desc= "Description 1......Description.....Description....." , Date =  DateTime.Now} ,  new HistoryItem { ID=2 , Desc= "Description 2......Description.....Description.....", Date =  DateTime.Now , Name = "Updated 2" } ,
                        new HistoryItem { ID = 3, Name = "Created 3"  , Desc= "Description 3......Description.....Description.....",Date =  DateTime.Now} ,  new HistoryItem { ID=4 , Desc= "Description 4......Description.....Description.....", Date =  DateTime.Now , Name = "Updated 4 " } ,
                        new HistoryItem { ID = 5, Name = "Created 5"  , Desc= "Description 5......Description.....Description.....",Date =  DateTime.Now} ,  new HistoryItem { ID=6 , Desc= "Description 6......Description.....Description.....", Date =  DateTime.Now , Name = "Updated 6" },
                        new HistoryItem { ID = 7, Name = "Created 7" , Desc= "Description 7......Description.....Description....." , Date =  DateTime.Now} ,  new HistoryItem { ID=8 , Desc= "Description 8......Description.....Description.....", Date =  DateTime.Now , Name = "Updated 8" } ,
                        new HistoryItem { ID = 9, Name = "Created 9"  , Desc= "Description 9......Description.....Description.....",Date =  DateTime.Now} ,  new HistoryItem { ID=10 , Desc= "Description 10......Description.....Description.....", Date =  DateTime.Now , Name = "Updated 10 " }                         
            // Return Sample Data
            return lst;

3. In ASP .Net page define some includes related to Yahoo UI Library as:

<!--CSS file (default YUI Sam Skin) -->
<link type="text/css" rel="stylesheet" href="">
<!-- Dependencies -->
<script src=""></script>
<script src=""></script>
<script src=""></script>
<!-- OPTIONAL: JSON Utility (for DataSource) -->
<script src=""></script>
<!-- OPTIONAL: Connection Manager (enables XHR for DataSource) -->
<script src=""></script>
<!-- OPTIONAL: Get Utility (enables dynamic script nodes for DataSource) -->
<script src=""></script>
<!-- OPTIONAL: Drag Drop (enables resizeable or reorderable columns) -->
<script src=""></script>
<!-- OPTIONAL: Calendar (enables calendar editors) -->
<script src=""></script>
<!-- Source files -->
<script src=""></script>

4. Define some ASP .Net tags as:

    <asp:ScriptManager ID="ScriptManager1" runat="server"   
    <input id="Button1" type="button" value="Get History data........." onclick='return getData();' /><br /><br />
    <div id="myContainer"></div>

5. Call to Page Method is done via Javascript as below:

<script language="javascript" >
    function getData() {        
        PageMethods.GetPageMethod(onSucceed, onError);
        return false;
    function onSucceed(result) {            
       // DataSource for a JavaScript function that returns data
        var dsLocalArray = new YAHOO.util.LocalDataSource(result);
       // DataTable columns defination
        var myColumnDefs = [{ key: "ID", label: "ID" }, { key: "Name", label: "Name" }, { key: "Desc", label: "Desc" }, { key: "Date", label: "Date"}];
       // DataTable constructor syntax
        var myDataTable = new YAHOO.widget.DataTable("myContainer", myColumnDefs, dsLocalArray, { sortedBy: { colKey: "Name", dir: "desc" }, rowSingleSelect: true });               
    function onError(result) {
        // Perform Error handling logic here.....
        alert('There is some thing wrong, Check again  .......');

So we are done with sample for fetching data via Javascript via Page methods.

The output will look like as:

Sample code can be downloaded from here. Rename file to, then extract to get code files

Software Architecture – ASP .Net 4.0 -For data bound control – EnablePersistedSelection

November 27, 2010

While exploring ASP .Net 4.0,I discovered that Microsoft has introduced a new property in ASP .Net 4.0 for data bound control like GridView,ListView named as EnablePersistedSelection.

In Asp .Net versions before 4.0, if a row is selected in Gridview then the same row number on all pages was get selected automatically. This was because of row selection on basis on index value.
But with ASP .Net 4.0, data Key based row selection is also supported. So now by enabling data key based row selection (by making EnablePersistedSelection=”True”), if a row is selected on page 1, later you move to next page 2, and so no row is selected on page 2, on returning to page 1 again, old row is still selected.

Keep enjoying coding in ASP .Net 4.0

MSDN Reference:

Software Architecture – Difference between id, name and clientid – For WPF/Silverlight/Window Forms/ASP .Net?

August 14, 2010

Lets focus on id and name first.

For WPF/Silverlight/Window Forms:
There is no concept of “id” in WPF, Silverlight and Windows Forms. But “name” is used to identify a control uniquely. So if you create a Textbox with “name” as “myTextBox”, then a variable will be created in code behind to access its properties.

For ASP .Net
In ASP .Net, “id” is used to uniquely identify a control in a page.

In ASP .Net, if you create a TextBox control as:

<asp:TextBox  ID="TextBox1" runat="server"></asp:TextBox>

Then in code behind file, a variable will be created as “TextBox1”, so in ASP .Net “ID” is used to uniquely identify a control.

So if you create a ASP .Net page with controls as:

<asp:TextBox  ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox  ID="TextBox1" runat="server"></asp:TextBox>

It will give a compile time error that two controls with same “ID” can’t co-exist in the same ASP .Net form.

If you will put control as below:

<asp:TextBox  name="TextBox1Name" ID="TextBox1" runat="server"></asp:TextBox>

A message will be shown as below:

Validation (ASP.Net): Attribute 'name' is not a valid attribute of element 'TextBox'.	

So in Asp .Net “name” is not allowed in server side control.

In ASP .Net, against following ASP .Net control

<asp:TextBox   ID="TextBox1" runat="server"></asp:TextBox>

Will transform in html as:

<input name="ctl00$MainContent$TextBox1" type="text" id="MainContent_TextBox1" />

Means that a “name” attribute is automatically created by concatenating the control hierarchy with “$” character and ” ID” values modified by concatenating with “_” character.
It is because in HTML ID and Name co-exist side by side.

id attribute was introduced only in DOM .ID supposed to be unique for the given document, while name can be the same for many elements (think of radio buttons group for instance).

According to, best comparison can be done as:

Id Attribute
• Valid on any element
• Each Id should be unique
• Can be used as anchor reference in URL
• Is referenced in CSS or URL with # sign
• Is referenced in JS with getElementById()
• Shares same name space as name attribute
• Must begin with a letter
• Is case sensitive

Name Attribute
• Valid only on a, form, iframe, img, map, input, select, textarea
• Name does not have to be unique
• Can not be referenced in CSS or URL
• Is referenced in JS with getElementsByName()
• Shares same name space as id attribute
• Must begin with a letter
• Is case sensitive
• Used on form elements to submit information


According to w3, following are main usage of ID attribute in HTML:

• As a style sheet selector.
• As a target anchor for hypertext links.
• As a means to reference a particular element from a script.
• As the name of a declared OBJECT element.
• For general purpose processing by user agents (e.g. for identifying fields when extracting data from HTML pages into a database, translating HTML documents into other formats, etc.).

What is clientid?
There is no concept of ClientID in Windows forms, Silverlight and WPF. It is only related to ASP .Net.
Clientid is used to give a systemically created id attribute to HTML control generated by running a ASP .Net control.

<script type="text/javascript">
    function DoSomething(){
        alert('<%= TextBox1.ClientID %>');

The above code will give “MainContent_TextBox1” showing the id of control.

Software Architecture -Error – IIS running for ASP .Net 2.0 and ASP .Net 4.0

August 10, 2010

Environment: IIS + ASP .Net 2.0 / 4.0

Problem Definition:
Suppose you have IIS running for ASP .Net 2.0 and ASP .Net4.0 , some application are running on ASP .Net 2.0 , so when a new application is deployed on ASP .Net 4.0, Application based on ASP .Net 2.0 will close with following message.

Server Application Unavailable

Windows Event log will show details as:

It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process.

When you run IIS 6.0 in worker process isolation mode, you can separate different Web applications and Web sites into groups known as application pools. An application pool is a group of one or more URLs that are served by a worker process or set of worker processes. Any Web directory or virtual directory can be assigned to an application pool.

So solution is to create separate application pool for each version of ASP .Net .
Secondly, select separate application pool in each web directory / web application configuration. This will solve the above issues.