Would there be any respite from corrupt Indian politicians!

Basically I am a positive guy and firm believer that India would come out of the bewilderment it’s in today. But from the day I got consciousness (about 15 years back when I was about 13-14) about my country, its goodness, its problems, I hardly see any progress.

Certainly we are growing economically; we can see better roads, better transportation, better life styles but then….still the same or rather more number of people begging around, more number of people bearing injustice, more poverty, more angriness, more dissatisfaction all over. Alas…it seems all the development is restricted for only certain section of our society especially our government officials, bureaucrats and politicians.

They can get away with anything… take the recent example of now (surprisingly) disgraced former Haryana police chief SPS Rathore, he did the most heinous crime of molesting a child…and instead of getting punished poor Ruchika Girhotra was punished and murdered. He is being trialed only since he had association with opposition parties guys not the ruling ones, otherwise nobody would have dared to touch him even after 19 years of his crime.

And then the veteran N. D. Tiwari…he has been the senior leader of congress holding all the highest positions like CM, Governor..and now when he is on the verge of end at 84 years...he crossed all the limits of decency with the act I feel ashamed even to mention it here…I am not sure how his family and near ones going to handle this. As far as his party or his colleagues are concerned it won't be much difficult for them to ignore this since he has already resigned and since these politicians are used to such disgracefulness and they know how to overcome it by making us foolish.

These politicians can easily create havoc , can easily bring animosity among us in the names of lanuguage, state, culture and easily get away with it.

I really see no respite from all these rubbish. I think we need a guy someone like Salman Khan in wanted…:)

Jokes apart, I see a ray of hope in guys like Nitish Kumar, Rahul Gandi, Nitin Gadakari..who would think out of the box of these politicians and work for the upliftment of people instead of their party..and yes we have arise to do our bit.

See you again….


WCF - Deployment and configurational issues

Today when I hosted WCF service in IIS 7.0. I got an error like

HTTP Error 404.3 - Not Found Description: The page you are requesting cannot be served because of the Multipurpose Internet Mail Extensions (MIME) map policy that is configured on the Web server. The page you requested has a file name extension that is not recognized, and is not allowed.

I explored and found solution.

What is intuitive here is that .svc extension is not recognized i.e. Http handler of .svc is not defined :) So the solution I found was that:
In the control panel > add remove programs > windows on off programs, select WCF HTTP Activation and WCF Non-HTTP Activation as in the picture:

Windows will take few minutes to update and after that your WCF Service will run smoothly on Vista and IIS7.

Also, I got some other issues while deploying WCF service on IIS7 on Vista OS, after installing below items under IIS7, things were fixed.

The Secret of Luck: Why Some People Have All the Luck

Why do some people have all the luck while others are perpetually unlucky? Professor Richard Wiseman of the University of Hertfordshire was determined to get to the scientific bottom of the phenomenon of luck, and what he discovered may surprise you:

I placed advertisements in national newspapers asking for people who felt consistently lucky or unlucky to contact me.

Hundreds of extraordinary men and women volunteered for my research and over the years, have been interviewed by me. I have monitored their lives and had them take part in experiments. The results reveal that although these people have almost no insight into the causes of their luck, their thoughts and behaviour are responsible for much of their good and bad fortune. Take the case of seemingly chance opportunities. Lucky people consistently encounter such opportunities, whereas unlucky people do not.

I carried out a simple experiment to discover whether this was due to differences in their ability to spot such opportunities. I gave both lucky and unlucky people a newspaper, and asked them to look through it and tell me how many photographs were inside. I had secretly placed a large message halfway through the newspaper saying: ‘Tell the experimenter you have seen this and win $50′.

This message took up half of the page and was written in type that was more than two inches high. It was staring everyone straight in the face, but the unlucky people tended to miss it and the lucky people tended to spot it.

Unlucky people are generally more tense than lucky people, and this anxiety disrupts their ability to notice the unexpected.

Why I am still not using ASP.NET MVC Framework !

It’s said “ASP.NET MVC Framework” is the biggest innovation in Microsoft web development since ASP.NET 1.0". Eventhough techies are of the view that APS.NET WebForms programming is here to stay many have started predicting its replacement with MVC within a year or so. Let me quote Jeffrey Palermo, author of “ASP.NET MVC in Action” - “For the .NET industry as a whole, I predict that ASP.NET MVC will be considered the norm for ASP.NET development by 2011”.

Questions like MVC or WebForms are dying; instead questions appearing nowadays are MVC or SharePoint. Check this http://odetocode.com/Blogs/scott/archive/2009/10/29/mvc-or-web-forms-a-dying-question.aspx

With so much of support of MVC, I also thought to implement my new project based on .net MVC Framework, so I jumped into various MVC tutorials, books, communities etc. And after about a week of research and working on sample project, I concluded to stay with WebForms until I am out the roadblocks I could perceive at this time. Eventhough I am going though rough patch due to my dad's health, I didn't stopped researching "Why MVC" using my smartphone, laptop etc.

I thought to share my research and path to conclusion which may help some of you guys.

Here it is:

MVC certainly has edge as far as technology and architecture is concerned, here are some those advantages of using MVC with ASP.NET instead of WebForms

  1. Provides fine control over rendered HTML, Cleaner generated HTML.
  2. Complexity of application logic is made easier to manage because of the separation of an application into model, view, and controller.
  3. It allows for easier parallel development; each developer can work on a separate component of the MVC pattern.
  4. It provides good support for TDD, mocking, and unit testing frameworks. TDD enables you to write tests for an application first, after which the application logic is developed. TDD, mocking, and unit testing are explained in Chapter 9, Testing an Application.
  5. It does not use ViewState or server-based forms, which allows you to have full control over the application's behavior and HTML markup.
  6. It uses RESTful interfaces for URLs, which is better for SEO (Search Engine Optimization). REST is short for REpresentational State Transfer—the concept of using URLs as the link to a resource, which can be a controller action method, rather than to physical files on the web server.
  7. A typical page size is small, because no unnecessary data is transferred in the form of hidden ViewState data.
  8. It integrates easily with client-side JavaScript frameworks such as jQuery or ExtJS.

But most of our projects are highly data driven and needs to use asp server controls like GridView, datagrid etc. extensively, which would need to rewritten for MVC. But our project cost and estimates are based on reusable server controls so it would be difficult to re-write the things in the same efforts. For this I have shelved the idea of using MVC with ASP.NET in my new project, instead would still stay with WebForms.

But I am not at all undermining the importance of MVC and have actually become the fan of MVC framework in ASP.net eventually so in the meanwhile I would be updating myself and creating some of the basic controls in MVC so that it can be reused in our projects instead of writing it.

And who know Microsoft may add kindda server controls which are MVC based.

Here are some other referenced that may help choosing between WebForms and MVC

1. http://blog.gadodia.net/choosing-between-webforms-and-mvc/
2. http://rachelappel.com/asp-net/asp-net-development-mvc-vs-web-forms/
3. http://weblogs.asp.net/shijuvarghese/archive/2008/07/09/asp-net-mvc-vs-asp-net-web-form.aspx

Thanks for reading this post!

Happy Coding!

Ranking Functions within SQL Server 2005

With SQL Server 2005, Microsoft introduced a number of new features. These new features make it easier for a DBA or SQL Server developer to code against and to maintain SQL Server databases. In this article I will discuss the new ranking functions provided with SQL Server 2005. These new functions make it much easier for you to code your T-SQL to associate a ranking to your result set. As I discuss each of the new ranking functions I will provide one or more examples to help illustrate how these new functions work.

What are Ranking Functions

Ranking functions are functions that allow you to sequentially number your result set. These functions can be used to provide you with a number of different sequential numbering schemes. For example you can number each row in your result set sequentially where the first row has a ranking number of 1, the second row has a ranking of 2, third row has 3, and so on. You can also use these ranking functions to sequentual number groups, so each group would have a numbering scheme of 1,2, 3, and then the next group would start over with 1, 2, 3, etc..

Test Data for My Examples

In order to provide examples of each ranking function I need to have some test data that the ranking function will process against. For my test data I will use a simple “Person” table. This table will consist of three columns “FirstName”, “Age” and “Gender”. Below is the code to create and populate my sample test data file.


FirstName VARCHAR(10),
Age INT,
Gender CHAR(1))
INSERT INTO Person VALUES ('Ted',23,'M')
INSERT INTO Person VALUES ('John',40,'M')
INSERT INTO Person VALUES ('George',6,'M')
INSERT INTO Person VALUES ('Mary',11,'F')
INSERT INTO Person VALUES ('Sam',17,'M')
INSERT INTO Person VALUES ('Doris',6,'F')
INSERT INTO Person VALUES ('Frank',38,'M')
INSERT INTO Person VALUES ('Larry',5,'M')
INSERT INTO Person VALUES ('Sue',29,'F')
INSERT INTO Person VALUES ('Sherry',11,'F')
INSERT INTO Person VALUES ('Marty',23,'F')


The first ranking function I will discuss is the ROW_NUMBER function. This function returns a sequential number starting at 1 for each row or grouping within your result set. The ROW_NUMBER function has the following calling syntax:

ROW_NUMBER ( )  OVER ( [  ]  )

Where the:

is a column or set of columns used to determine the grouping in which the ROW_NUMBER function applies sequential numbering.

” is a column or set of columns used to order the result set within the grouping (partition).

To demonstrate how to use the ROW_NUMBER function, my first example below will sequentially number all the rows in my Person table, and order them by Age.


FROM Person

Here is the result set for the above T-SQL code:

Row Number by Age    FirstName  Age

-------------------- ---------- -----------
1 Larry 5
2 Doris 6
3 George 6
4 Mary 11
5 Sherry 11
6 Sam 17
7 Ted 23
8 Marty 23
9 Sue 29
10 Frank 38
11 John 40

Here you can see I have sequentially numbered all my Person table rows starting from 1, and the result set is ordered by the Age column. This ordering was accomplished by placing the “ORDER BY Age” criteria in the ORDER BY clause of the ROW_NUMBER function.

Suppose you do not want your result set to be ordered, but you want to simply just sequentially number each row. The ROW_NUMBER function requires an ORDER BY clause, so something is needed in this clause. In the following query I specified “SELECT 1” for the ORDER BY clauses, doing this just returned my rows physically how they where stored, and sequentially numbered them starting from 1:

SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [Row Number by Record Set],

FROM Person

Here is the result set from running the above query:

Row Number by Record Set FirstName  Age

------------------------ ---------- -----------
1 Ted 23
2 John 40
3 George 6
4 Mary 11
5 Sam 17
6 Doris 6
7 Frank 38
8 Larry 5
9 Sue 29
10 Sherry 11
11 Marty 23

The ROW_NUMBER function not only allows you to order the entire row set, but you can also use the PARTITION clause to sequentially number groups of rows. Rows will be sequentially numbered within each unique partition value. The sequential number will restart at 1 for each new partition value in your record set. Take a look at the following query:


FROM Person

When I run this query, this is my result set:

Partition by Gender  FirstName  Age         Gender

-------------------- ---------- ----------- ------
1 Doris 6 F
2 Mary 11 F
3 Sherry 11 F
4 Sue 29 F
1 Larry 5 M
2 George 6 M
3 Sam 17 M
4 Ted 23 M
5 Marty 23 M
6 Frank 38 M
7 John 40 M

In this example I partitioned by Gender, and ordered by Age. Doing this allowed me to sequentially number the female records in my Person table by age, and then have the sequential numbering start over again for the male group.

RANK Function

Sometimes you want a row that has the same order by column value as another row to have the same ranking. If this is the case then the RANK() function will help you. The RANK function has the following calling syntax:

RANK ( )  OVER ( [  ] > )

Where the:

is a column or set of columns used to determine the grouping in which the RANK function applies sequential numbering.

<order_by_clause>” is a column or set of columns used to order the result set within the grouping (partition).

The RANK function sequentially numbers a record set, but when two rows have the same order by value then they get the same ranking. The ranking value still gets incremented when two rows have the same order by value, so that when a new ranking order by value is encountered the ranking value on that new row will be 1 more than the number of proceeding rows. Let me show you a couple of examples to help you better understand the RANK function.

In this first example I want to rank my record set by Age:


FROM Person

Here is the output for this command:

Rank by Age          FirstName  Age

-------------------- ---------- -----------
1 Larry 5
2 Doris 6
2 George 6
4 Mary 11
4 Sherry 11
6 Sam 17
7 Ted 23
7 Marty 23
9 Sue 29
10 Frank 38
11 John 40

By looking at this output you can see that whenever rows have the same Age value their “Rank by Age” value are the same. You can see this for “Doris” and “George”, “Mary” and “Sherry”, as well as “Ted” and “Marty”. Each of these row pairs have the same “Rank by Age” value. Note that “Doris” and “George” both have a ranking of 2, but the ranking for “Mary” the next unique Age doesn’t have a ranking value of 3, but instead has a ranking of 4. This is because “Mary” is the forth record returned in the record set, and the RANK() functions takes this into account when setting the ranking value of the next unique “Rank by Age” value.

If you want to have multiple rankings in your record set, where each ranking is for a specific group you need to use the “PARTITION BY” clause of the RANK function. Below is an example where I grouped my ranking by Gender, and ordered each ranking by Age:

SELECT RANK() OVER (PARTITION BY Gender ORDER BY Age) AS [Partition by Gender],

FROM Person

Here is the results of running the above query:

Partition by Gender  FirstName  Age         Gender

-------------------- ---------- ----------- ------
1 Doris 6 F
2 Mary 11 F
2 Sherry 11 F
4 Sue 29 F
1 Larry 5 M
2 George 6 M
3 Sam 17 M
4 Ted 23 M
4 Marty 23 M
6 Frank 38 M
7 John 40 M

Here you can see that the “F” Gender started ranking at 1 and goes through 4, then the ranking starts over with 1 when the first “M” Gender is encountered.


The DENSE_RANK function is similar to the RANK function, although this function doesn’t produce gaps in the ranking numbers. Instead this function sequentially ranks each unique ORDER BY value. With the DENSE_RANK function each row either has the same ranking as the preceeding row, or has a ranking 1 greater then the prior row. The DENSE_RANK function has the same syntax as the RANK function.

Here I use the DENSE_RANK function to rank all my Person records by Age:


FROM Person

This code produces the following output:

Dense Rank by Age    FirstName  Age

-------------------- ---------- -----------
1 Larry 5
2 Doris 6
2 George 6
3 Mary 11
3 Sherry 11
4 Sam 17
5 Ted 23
5 Marty 23
6 Sue 29
7 Frank 38
8 John 40

Here you can see the “Dense Rank By Age” column numbers are sequential without any gaps. And when two rows have the same ORDER BY value they have the same ranking like “Ted” and “Marty”.

NTILE Function

The last ranking function is the NTILE function. This function is used to break up a record set into a specific number of groups. The NTILE function also uses similar syntax as the other ranking functions.

In this first example, I want to group my Person records into three different groups of records. I want these groups to be based on the Age column. To do that I would run the following T-SQL:

SELECT FirstName,

NTILE(3) OVER (ORDER BY Age) AS [Age Groups]
FROM Person

Here is my result set from the above T-SQL command:

FirstName  Age         Age Groups

---------- ----------- --------------------
Larry 5 1
Doris 6 1
George 6 1
Mary 11 1
Sherry 11 2
Sam 17 2
Ted 23 2
Marty 23 2
Sue 29 3
Frank 38 3
John 40 3

In my result set I ended up with three different “Age Groups”. The first age group goes from Age 5 to Age 11, the second age group goes from 11 to 23, and the last age group is 29 to 40. The NTILE function just evenly divides your record set into the number of groups the NTILE function requests. By using the NTILE function each record in a group is give the same ranking.

The NTILE function is very useful if you only want to return a specific grouping of records. Below is an example where I returned only the middle group (Age Group = 2) from my prior example:

SELECT FirstName,

Age AS [Age Group]
FROM ( SELECT FirstName,
FROM Person) A
WHERE AgeGroup = 2

Here you can see I only returned the second Age Group:

FirstName  Age         Age Group

---------- ----------- -----------
Sherry 11 11
Sam 17 17
Ted 23 23
Marty 23 23


Coding a process to sequential number your record sets used to take a number of lines of code. SQL Server 2005 solved this coding dilemma by providing some new ranking functions. Hopefully the next time you need to sequential number a record set, one of the new ranking functions in SQL Server 2005 will make your number task, a trivial task.

Reference: http://www.databasejournal.com/features/mssql/article.php/3661461/New-Ranking-Functions-within-SQL-Server-2005.htm

Infosys’ success secret

The three aspects of ensuring success for any entrepreneur was innovation, ability to use innovation to create service and products that add value to customers and the ability to communicate the value to customers, Infosys Chairman N R Narayana Murthy said.

"Think of innovation and marketing as two most important instruments for creating a wonderful organisation and tremendous brand equity," Murthy advised entrepreneurs at the launch of a new marketing book, "No Marketing Money" authored by Jessie Paul, a former global brand manager at Infosys.

Using Innovative platform that does not cost too much money could help entrepreneurs to create brand equity, he said sharing his own experience of building Infosys from a little known brand to a globally recognised brand.
He said during a survey conducted in 1992 with prospective employees on the company they would like to join, zero per cent opted for Infosys. This dismal picture drove him to take a vow to change it. "We will be number one in India in five years," he had told his colleagues then.

His confidence was met with some scepticism by colleagues who wondered how a small company with less resources could hope to compete with richer and bigger companies, he recalled.

"We will do new unusual things," he had told his colleagues. "We will do what other companies did not do," he said reminiscing over the transformation of a company to a leading global software firm.

"Think of new ideas and think of platforms that do not cost too much and that will get people to talk about you, magazines to write about you," he said, adding communicating unusual ideas would attract people.

Paul said the book was a guide for companies especially startups to establish themselves and grow rapidly on a relatively limited budget. It provides actionable insights and advice on how to steer as well as manage brands.

Girish Paranjpe, Joint CEO, IT Business and Member of the Board, Wipro, said "Clear Positioning and Innovative marketing are required if more Indian firms are to play a role on the global stage."

Reference: http://infotech.indiatimes.com/News/Know-Infosys-success-secret/articleshow/5021209.cms

Developing High-Performance ASP.NET Applications

1. Disable session state when you are not using it.
2. Choose your session-state provider carefully.
3. Avoid unnecessary round trips to the server.
4. Use Page.IsPostBack to avoid performing unnecessary processing on a round trip.
5. Use ASP.NET server controls in appropriate circumstances.
6. Save server control view state only when necessary.
7. Leave buffering on unless you have a specific reason to turn it off.
8. Do not rely on exceptions in your code.
9. Use the common language runtime's garbage collector and automatic memory management appropriately.
10. If you have a large Web application, consider performing pre-batch compilation.
11. Recycle processes when running ASP.NET Web applications on Internet Information Services 5.0.
12. Adjust the number of threads per worker process for your application if necessary.
13. Use the HttpServerUtility.Transfer method to redirect between pages in the same application.
14. Make all modules in the request pipeline as efficient as possible.
15. Use early binding in Visual Basic .NET or JScript code.
16. Port call-intensive COM components to managed code.
17. Avoid single-threaded apartment (STA) COM components.
18. Use SQL Server stored procedures for data access.
19. Use the SqlDataReader class for a fast forward-only data cursor.
20. Choose the data viewing mechanism appropriate for your page or application.
21. Cache data and page output whenever possible.
22. For applications that rely extensively on external resources, consider enabling Web gardening on multiprocessor computers.
23. Be sure to disable debug mode.
24. Tune the configuration files for your Web server computer and specific applications to suit your specific needs.
25. Enable authentication only for those applications that need it. Like
a. Configure your application to the appropriate request and response encoding settings.
b. Consider disabling AutoEventWireup for your application.
c. Remove unused modules from the request-processing pipeline.


  1. Developing High-Performance ASP.NET Applications ( http://msdn.microsoft.com/en-us/library/5dws599a(VS.71).aspx )
  2. ASP.NET Best Practices for High Performance Applications ( http://www.codeproject.com/KB/aspnet/ASPNET_Best_Practices.aspx )
  3. Improving ASP.NET Performance ( http://msdn.microsoft.com/en-us/library/ms998549.aspx )
    10 Tips for Writing High-Performance Web Applications (
    http://msdn.microsoft.com/hi-in/magazine/cc163854(en-us).aspx )
  4. 10 ASP.NET Performance and Scalability Secrets ( http://www.codeproject.com/KB/aspnet/10ASPNetPerformance.aspx )
  5. Checklist: ASP.NET Performance ( http://msdn.microsoft.com/en-us/library/ms998596.aspx )

Caching in ASP.net

The main benefits of caching are performance-related: operations like accessing database information can be one of the most expensive operations of an ASP page's life cycle. If the database information is fairly static, this database-information can be cached.

Caching helps us to achieve three important aspects of QoS (Quality of Service):

  1. Performance - Caching improves application performance by minimizing data retrieval and formatting operations.
  2. Scalability - Since caching minimizes data retrieval and formatting operations, it reduces the load on server resources thus increasing the scalability of the application.
  3. Availability - Since the application uses data from a cache, the application will survive failures in other systems and databases.

Caching Options in ASP.NET

ASP.NET supports three types of caching for Web-based applications:

  1. Page Level Caching (called Output Caching)
  2. Page Fragment Caching (often called Partial-Page Output Caching)
  3. Programmatic or Data Caching

Output Caching

Page level, or output caching, caches the HTML output of dynamic requests to ASP.NET Web pages. The way ASP.NET implements this (roughly) is through an Output Cache engine. Each time an incoming ASP.NET page request comes in, this engine checks to see if the page being requested has a cached output entry. If it does, this cached HTML is sent as a response; otherwise, the page is dynamically rendered, its output is stored in the Output Cache engine.

Output caching is easy to implement. By simply using the @OuputCache page directive, ASP.NET Web pages can take advantage of this powerful technique. The syntax looks like this:

Partial-Page Output Caching

Partial-Page Output Caching, or page fragment caching, allows specific regions of pages to be cached. ASP.NET provides a way to take advantage of this powerful technique, requiring that the part(s) of the page you wish to have cached appear in a User Control. One way to specify that the contents of a User Control should be cached is to supply an OutputCache directive at the top of the User Control. That's it! The content inside the User Control will now be cached for the specified period, while the ASP.NET Web page that contains the User Control will continue to serve dynamic content.

Data Caching

Programmatic or data caching takes advantage of the .NET Runtime cache engine to store any data or object between responses. That is, you can store objects into a cache

To store a value in the cache, use syntax like this:

Cache["myblogpage"] = bar; or Cache.Insert("myblogpage", bar);

To retrieve a value, simply reverse the syntax like this:

sampleVar = Cache["myblogpage"];


Caching explained here:


Caching including other state managements explained here:


Career Path finder

Appreciate the effort spent to prepare this chart, a bit late for us though…but it can be useful for your relatives or friends..!

Giving SOAP a REST

Many developers will be surprised to learn that SOAP isn't the only game in town for Web services interfacing. REST offers a perfectly good solution for the majority of implementations, with greater flexibility and lower overhead. Developers need to stop reaching immediately for SOAP and start choosing the right technology for the application.

What is REST?

REST (representational state transfer) is an approach for getting information content from a Web site by reading a designated Web page that contains an XML (Extensible Markup Language) file that describes and includes the desired content.

Born of a UC-Irvine doctoral dissertation by Roy Fielding in the year 2000, REST has grown into a force in the application development community, offering a simplified method of using HTTP protocols to work directly with data.

Fielding describes REST as an architectural style that leverages the modern Web, adding "REST emphasizes scalability of component interactions, generality of interfaces, independent deployment of components, and intermediary components to reduce interaction latency, enforce security, and encapsulate legacy systems."

Delving into the short definition of REST, a basic use case for it would be an online publisher making available syndicated content. Subscribers would need only to know the URL (Uniform Resource Locator) for the page where the XML file was located, read it with a Web browser, interpret the content data, and reformat and use it appropriately.

  1. Overview of REST in WCF (http://msdn.microsoft.com/en-us/netframework/dd547388.aspx )
  2. What is REST(http://rest.blueoxen.net/cgi-bin/wiki.pl?WhatIsREST)
  3. Representational State Transfer - REST Tutorial (http://searchsoa.techtarget.com/generic/0,295582,sid26_gci1317288,00.html)
  4. How I Explained REST to My Wife (http://tomayko.com/writings/rest-to-my-wife)
  5. REST (http://www.xfront.com/sld001.htm)
  6. http://www.devx.com/DevX/Article/8155
  7. REST vs. SOAP (http://www.innoq.com/blog/st/2006/06/30/rest_vs_soap_oh_no_not_again.html)

Get Logging in database with the Enterprise Library 4.1

Applications generate logs to keep track of their health, to assist in debugging, and for auditing purposes. Logging makes applications more supportable by giving developers a standardized method for recording application information. The Logging Application Block is designed to support flexible and robust logging configurations.

The heart of the Enterprise Library Logging Application Block is its TraceListeners, which are essentially the conduit for which event messages get to their intended destinations. Enterprise Library 2.0 provides the following TraceListeners:

  • Database TraceListener
  • Email TraceListener
  • Flat File TraceListener
  • Formatter Event Log TraceListener
  • Msmq TraceListener
  • System Diagnostics TraceListener
  • WMI Trace Listener

The usefulness of each TraceListener is fairly obvious. You would use the Database TraceListener to log trace messages to a database. The Email TraceListener is for sending trace messages via email.

Many companies require audit logging, especially for applications that require history records (or audit trails) of operations performed on sensitive information. This type of logging tends to contain larger amounts of information. In some cases, it may include entire database records. If the auditing is for security purposes, it tends to capture previous and current state as well as who made the change.

Logging to a database makes it easy to write queries against the logged messages for troubleshooting purposes. The logging block comes bundled with an out-of-the-box database trace listener that is capable of writing to a data store.

Lets see then how can we configure database logging:

To use the database-driven logging, you first need to execute a SQL script (supplied with Enterprise Library) to create the logging database. Run the LoggingDatabase.sql file that you'll find in the C:\EntLib41Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts folder. This will create a database named Logging in your SQL Server along with the required tables and stored procedures.

Add a connection string for it, in addition to your default database:

Using the name of the logging database connection create a logging configuration tag in web.config as follows

As seen, The logging block configuration schema consists of four key elements named Category Sources, Special Sources, Trace Listeners, and Formatters. By default, the logging application block creates a Formatted EventLog TraceListener entry and configures it as the category source with the Text Formatter as the default formatter.

Then generate an exception and you will see a error record in the log table.

Here are some great links to start with Microsoft Enterprise Library



धन्यवाद |

Using XPathDocument

using Systm.XML.Xpath

//creates an instance of XPathDocument class and loads xml
if (System.IO.File.Exists(Server.MapPath("/portal/BrowserCookieValidation.xml")))
XPathDocument doc = new XPathDocument(Server.MapPath("BrowserCookieValidation.xml"));
//An XPathNavigator object acts like a cursor, addressing a node in the XML document at a time
XPathNavigator nav = doc.CreateNavigator();
string message = String.Empty;
// Compile a standard XPath expression
XPathExpression expr = nav.Compile("/CookieValidation/OutCompany[@OCID=" + OCID.ToString() + "]");
//select node with ocid = 131
XPathNodeIterator iterator = nav.Select(expr);

//if node is found, count would be greater than 0 and company specific messsaage would come
if (iterator.Count > 0)
{ //Iterate through the selected nodes
while (iterator.MoveNext())
//if attribute is not there but node is there,null will be returned
if (iterator.Current.GetAttribute("ErrorMessage", string.Empty) != null)
message = iterator.Current.GetAttribute("ErrorMessage", string.Empty);
else //get default message
message = GetDefaultMessage(doc, nav);
//in case ocid node is there, but blank errormessage, bring default message
if (string.IsNullOrEmpty(message))
message = GetDefaultMessage(doc, nav);

//put value in the labbel
msgContainer.Text = message;

The XMLHttpRequest Instantiation with explanations

function getXMLHTTP() {
var XMLHTTP = null;
if (window.ActiveXObject) {
try {
//this legacy approach failed, try other object
XMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
//ie implementation
XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
} else if (window.XMLHttpRequest) {
try {
//mozilla based. This line tries to create a new
//request object, but it won’t work for every browser type.
XMLHTTP = new XMLHttpRequest();
} catch (e) {
return XMLHTTP;

//This line asks for an instance of the request object and assigns it to
//the variable XMLHTTP

if (XMLHTTP != null) {
//These parameters tell the request object how we want it to connect to the server.
//“GET” indicates how to send the data (the other option is “POST”).
//2nd parameter is the url for the serverside script that will respond to the request.
//3rd parameter, This means that the request should be asynchronous. That is, the code
//in the browser should continue to execute while it’s waiting for the server to respond.
XMLHTTP.open("GET", "ajax.aspx?sendData=ok", true);

/* if want to post, which can be read using Request.Form on server side
XMLHTTP.open("POST", "ajax.aspx");
XMLHTTP.onreadystatechange = stateChanged;

//This is the line that tells the browser what code to call
//when the server responds to the request. This is a reference to a
//function, not a function call. So make sure you don’t include any parentheses at
//the end of the function name.
XMLHTTP.onreadystatechange = stateChanged;
//You’re sending the request here, null means you’re not sending
//any extra data with the request

function stateChanged() {
//readyStateis the status code message returned by the server, for example, “OK” for status 202.
//Contains information sent back by the server in XML format.
if (XMLHTTP.readyState == 4 && XMLHTTP.status == 200) {
//response TextContains textual information sent back by the server.

The XMLHttpRequest Instantiation with explanations

Autographs of Indian Legends

A P J AbdulKalam

Abul Kalam Azad Maulana

Amartya Sen, Dr.

Ambedkar B. R., Dr.

Amithab Bachchan

Asha Bhosle

Baba Amte

Bala Gangadhar Tilak

Bipin Chandra Pal

Bismillah Khan Ustad

C.K. Nayudu

Chandu Borde


Chittaranjan Das

Dev Anand

Gopal Krishna Gokhle

Har Gobind Khorana

Hariprasad Chaurasia Pandit

Indira Gandhi

J.R.D. Tata

Jagjivan Ram

Jawaharlal Nehru

Jayprakash Narayan

Kapil Dev

Khan Abdul Gafar Khan

Koneru Humpy

Lal Bahadur Shastri

Lala Amarnath

Lata Mangeshkar

M.F. Husain

Mahatma Gandhi

Mangalampalli Balamuralikrishna

Manmohan Singh, Dr.

Maulana Abul Kalam Azad

Morarji Desai

Mother Teresa

P. Susheela

Sarvepalli Radhakrishna

Rahul Bajaj

Raj Kapoor

Rajendra Prasad, Dr.

Rajiv Gandhi

Raman C.V.

Ratan Tata

Ravi Shankar Pandit

Ravindranath Tagore

S.P. Balasubrahmanyam

Sachin Tendulkar

Sarath chandra bose

Sardar vallabhai patel

Sarojini naidu

Satyajit Ray

Subbulakshmi M.S.

Subhash Chandra Bose

Sunil Gavaskar

Sunita Williams

Tanguturi Prakasam panthulu

Vajpayee Atal Bihari

Vikram Sarabhai, Dr. (Gujarat)

Vinoba Bhave

Viswanathan Anand


Zakir Husain, Dr.