December 2, 2015

Accessing the ASP.NET Web Configuration Tool in Visual Studio 2013

Visual Studio 2013 Preview has been release, hide few features which was present initially in previous versions. One of them is "Asp.Net Configuration Manager" which is no longer in Visual Studio 2013 Preview. This happened due to the removal of Cassini or Visual Studio Development Server from the product. Many peoples are still want to use the tool. I found these instruction in MSDN blog but before of use make sure that this will work only for sites running on the .Net Framework 4.0 and above. Follow these steps;

1. Open the Command Prompt (not as administrator)
2. Navigate to the folder where IIS Express is installed on your machine.
3. In the command line spin up a IISExpress site with the following prompt: “iisexpress.exe /path: 
C:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles /vpath:”/ASP.NETWebAdminFiles” /port:[port] /clr: 4.0 /ntlm” using the following values for the [param]:
   NOTE: [port] – any port you have free in IISExpress like 8082
4. This should launch an IISExpress instance of the Configuration Manager Site

5. Open your browser
6. In the URL enter the following 
Substituting the [appPath] with the absolute path to the Visual Studio Project folder with the solution file in it.

Congratulations, you now have your Web Site Administration Tool running as before. Stay tune:)

8 Famous Quotes to Help You Embrace Fear and Achieve Success

You can find many words of wisdom but I like 8 of them quite resourceful and these quotes will surely help you embrace fear and achieve success. When offering career advice to young professionals and entrepreneurs, the two things that always top of list are to find a mentor and to read voraciously. 

Throughout the course of life, you have been blessed with multiple mentors -- mostly teachers, professors, bosses or colleagues. In addition, you have gathered useful advice from reading, and observing the actions of individuals who identify as some of the world’s best leaders, both past and present. 
The following are 8 notable quotes from these “leaders” that have inspired me and helped to shape my principles.

“Develop success from failures. Discouragement and failure are two of the surest stepping stones to success.” – Dale Carnegie

"There are only two ways to live life. One is as though nothing is a miracle. The other is as though everything is." – Albert Einstein

"Do not look for approval except for the consciousness of doing your best." – Andrew Carnegie

"The true measure of a person is how they treat someone who can do him absolutely no good." – Samuel Johnson

"You've got to be very careful if you don't know where you are going because you might not get there." – Yogi Berra

“Expect more than others think possible.” – Howard Schultz

"If people aren't calling you crazy, you aren't thinking big enough." – Richard Branson

“Never, never, never give up.” – Winston Churchill

To me, the key takeaway is to push yourself through fear and uncertainty and place your best foot forward no matter what happens. The point is -- put your plans in motion, work hard and be willing to adapt along the way.

How to Become a Great Leader?

Yesterday I read an article which is very resourceful and points many areas which we improve can make us a Great Leader in our domain. All of need is to work hard and stay focus of what you are trying to achieve  Because without focusing on your goals, you can't make the right alignment with your company if so then it will degrade your expertise the company wants in you.

Leadership is a hot topic and will always be one. We seem to linger in a perpetual leadership vacuum. Today's Presidents and CEO s  generals and coaches, some of them don't stand in comparison with the great leaders of the past - or so we are told - and in times of crisis, people cry out for someone who can show them a way to escape the looming threat. There’s a general myth that leaders are born rather than made, that somehow Nature produces a peculiar species of human being who is bigger, more powerful, smarter, braver, and more charismatic than the rest.

But waiting for such a rare bird is futile, for there are many crises that never find the natural born leader it needs. The real challenge in leadership is to find a way to build leaders. The main way that business schools and government departments attempt this is by studying the past. Learning from history has its advantages, naturally. There are lessons to be learned about how World War II was won, why the Chicago Bulls were such a successful basketball team, and why Wall St. banks, led by greed and short-sightedness, created the financial collapse of 2008.

But today's crises never completely mirror yesterday's, and it would be better in the first place to build leaders who can prevent crises before they arise. In my view, a great leader is inspiring, uplifting, a unite of differences, and someone who brings out the best in human aspirations. I named this model "the soul of leadership” and set out to see if leaders with a soul could be trained.

Knowing that business, politics, and the military are not spiritual enterprises, I didn't formulate the training along "soft" or idealistic lines. Instead, I used a "hard" criterion: what groups actually need. If you aspire to be a great leader, the first requirement is that you look and listen, so that you can find out the true needs that a situation demands to be fulfilled. 

There are seven such needs:

1. Safety, security

Situations of threat and instability. People feel insecure. Discontent is in the air. You can see nervous faces, feel the prevailing anxiety. Who is going to make the situation feel safer?

2. Achievement, success

Situations of unrealized achievement. People feel unsuccessful. They want to be more productive, but there’s not enough fire or passion. Who is going to step up and provide the motivation so sorely needed?

3. Cooperation

Situations that are incoherent and fragmented. There’s no team spirit. The group disintegrates into bickering and petty wrangling. Meetings go on forever but reach no conclusion. Who’s going to be the glue that brings coherence to the situation?

4. Nurturing, belonging

Situations mired in bad feeling and apathy. Everyone is going through the motions, doing what they need to do but inside feeling totally disengaged. The atmosphere is stale and routine. There’s no personal support or trust. Who’s going to bring heart to the situation and make others feel that they belong?

5. Creativity, progress

Situations dominated by old solutions and stale ideas. People feel stymied. The atmosphere has no creativity; it feels like yesterday’s news. Everyone agrees that something new is needed, but all that emerges are small variations on the status qua. Who’s going to bring the spark of creativity to the situation?

6. Moral values

Situations that are spiritually empty and corrupt. The weak feel hopeless, the strong are cynically taking advantage. People talk about righting wrongs and bringing back the right values, but no one knows where to start. The future feels like wishful thinking; the present is oppressive and suffocating. Who will bring hope and a renewed sense of innocence?

7. Spiritual fulfilment

Situations that symbolize the human condition. People are asking the big questions: Who am I? Why am I here? Many are seeking for God. There is talk of a higher reality, yet faith is lacking. Who can bring the light and demonstrate that holiness is a living reality?

Having looked and listened, you will know the situation you are in and the need that is crying out to be fulfilled. As you can see, the "hard" criterion that shaped this model of leadership eventually leads to moral values and spirituality, because in reality those aren't "soft" needs. Every human being has a yearning for them. But unless the basic needs are fulfilled, appealing to a group's ideals is usually futile.

The most common cause of leadership failure is ego, which means that someone is looking out for number one rather than the group. Ego is a legitimate basis for action - it's the second need above safety and security. We all want the good things in life; our instinct is to provide for "I, me, and mine." But the collapse of Wall St. and many disastrous wars have resulted when leaders get stuck on ego. 

You can be a great leader, with all the rewards this carries, while still serving the needs of the whole group. In essence, that's what the soul of leadership is all about.

How to Self-Promote without Being a Jerk?

Yesterday I read an article to self promoting yourself without being a Jerk. Is it possible to genuinely be interested in the needs of others, and still promote yourself? Absolutely, otherwise all the good people would be starving in the streets. But doing so requires that you skip the sort of "me first", self-centred promotion that many utilize.

Here are some tips for getting the right kind of attention:

Start with the facts. Keep your resume, bio and LinkedIn profile in perfect order. Be factual, clear and complete; If you doubled sales in a year, say so.

Plenty of people do the opposite: They make boastful claims in an article or email, but their profile is lacking the most basic details. Make it very easy for people to get facts about what you have accomplished. The key word here is "facts." Don't brag, just tell the truth.

Acknowledge others. State your accomplishments in terms of how you have helped others. If you have clients, list the ways they have benefitted from working with you. If you volunteer, be proactive in supporting your favorite non-profits. When your team wins, give credit to the other team members.

Be helpful. The best articles, blog posts, comments and discussion topics serve to help other people. The wrong way to get a new client is to say, "I'm the best, hire me." The right way is to be so helpful that it becomes obvious to others that you are someone who adds value and brings the right attitude to tough challenges. 

Beware... people are very good at spotting insincere contributions. Don't simply pretend to help others; actually help them.

Share freely. Few things bother people more than a "teaser" article that forces readers to share their contact information before gaining access to more valuable content. I get the sales and marketing reasons for using such an approach, but a far better strategy is to share freely and make it easy for people to contact you if they value what you have shared.

Be expert. It is much better to be expert than to say you are an expert. If you have worthwhile capabilities, use them. Write a book that imparts genuine insights. Teach others valuable skills. Be calm and focused in stressful situations. Look for actual solutions, instead of simply parroting tired, old phrases. Use your abilities in ways that other people value.

When you don't know the answer, just say so. It is human nature to fall into the trap of thinking you have all the answers. Newsflash: no one has all the answers. If you want to earn credibility, be the first to admit when you are over your head. Even better, send people to other experts who are equipped to answer their current questions; paradoxically, doing so will raise your credibility.

One last caution... don't be full of yourself. Never use these words to describe yourself: thought leader, visionary, insightful, or genius.

And please - if you are over the age of 20, never put your GMAT, LSAT, or SAT scores on your profile. Once you get into a school, it is bad form to tell others how you did it. Listing your board scores is equivalent to saying, "I'm smart, but I lack common sense."

Different Ways To Test Your Website In Older Version Of IE

There are few method present to test your site in older versions of IE to make sure that its working fine in every browser because the annonymous user may have old browser when they visit to your websites. You can test your website in following ways:

Firstly IE8, IE9, IE10 and IE11 all have developer tools (use press F12 to open it) these allow you to change your document and browser mode to go back to older rendering engines such as IE6. I delivered a session on IE9 developer tools and most of this is valid for IE10 too. With IE11 comes a new set of greatly improved tools.

The scanner allows you to enter a web address. The scanner then uses a node.js services (which is available on GitHub) to go fetch the website and interrogate it to locate common problems, it then provides a report which details what you may need to do to fix you website so that it works well in IE and also other stands based browsers.

For the most accurate results you will probably want to use Virtual Machines so that you can run the browsers in a real world environment. This is by far and away the most popular way to do browser testing in my experience. The good folk at have produced VM’s for all the various browsers and operating system combinations (IE6-IE11). These VM’s run on Windows, Linux and Mac and in numerous Virtualisation flavours including Parallels, VMWare and VirtualBox.

4. HOSTED VIRTUAL MACHINES (BROWSERSTACK) provides a 3 month free trial for BrowserStack which allows you to test IE6-10 (and every other major browser like Chrome, Opera, Safari, Firefox as well as iOS and Android emulators) inside of your browser. There are also browser plugins available for Chrome and Firefox which make launching BrowserStack even easier. With BrowserStack you can simply start up a new Virtual machine in the cloud running practically any OS and then test your website in that environment.

One way to run multiple versions of Internet Explorer on one PC is to run the older version(s) of Internet Explorer using Windows XP Mode on a Windows PC running Windows 7 Professional, Enterprise, or Ultimate edition. (Windows XP Mode is an optional downloaded feature of Windows 7 Professional, Enterprise, and Ultimate editions that provides you a pre-installed image of Windows XP SP3 that you run using Windows Virtual PC..)

It is even possible to set up and run multiple XP Modes on one Windows 7 machine, thereby allowing you to run Internet Explorer versions 6, 7, 8, and 9 simultaneously on a single machine.

11 Simple Concepts to Become a Better Leader

I read an article written by Dave KerpenCEO, Likeable Local, NY Times Best-Selling Author & Keynote Speaker in which he defines the 11 simple concepts that help anyone to become a better leader in the world. All you need is to focus on goal and figuring out how to achieve it. It will help you in your job, business, relationships, and life. All of the concepts are simple, and yet, perhaps in the name of revenues or the bottom line, we often lose sight of the simple things - things that not only make us human, but can actually help us become more successful. Below are the eleven most important principles to integrate to become a better leader:

1. Listening

"When people talk, listen completely. Most people never listen." - Ernest Hemingway

Listening is the foundation of any good relationship. Great leaders listen to what their customers and prospects want and need, and they listen to the challenges those customers face. They listen to colleagues and are open to new ideas. They listen to shareholders, investors, and competitors. Here's why the best CEO's listen more.

2. Storytelling

"Storytelling is the most powerful way to put ideas into the world today." - Robert McAfee Brown

After listening, leaders need to tell great stories in order to sell their products, but more important, in order to sell their ideas. Storytelling is what captivates people and drives them to take action. Whether you're telling a story to one prospect over lunch, a boardroom full of people, or thousands of people through an on-line video - storytelling wins customers.

3. Authenticity

"I had no idea that being your authentic self could make me as rich as I've become. If I had, I'd have done it a lot earlier." -Oprah Winfrey

Great leaders are who they say they are, and they have integrity beyond compare. Vulnerability and humility are hallmarks of the authentic leader and create a positive, attractive energy. Customers, employees, and media all want to help an authentic person to succeed. There used to be a divide between one’s public self and private self, but the social internet has blurred that line. Tomorrow's leaders are transparent about who they are on-line  merging their personal and professional lives together.

4. Transparency

"As a small businessperson, you have no greater leverage than the truth." - John Whittier

There is nowhere to hide any more  and businesspeople who attempt to keep secrets will eventually be exposed. Openness and honesty lead to happier staff and customers and colleagues. More important, transparency makes it a lot easier to sleep at night - unworried about what you said to whom, a happier leader is a more productive one.

5. Team Playing

"Individuals play the game, but teams beat the odds." - SEAL Team Saying

No matter how small your organization, you interact with others every day. Letting others shine, encouraging innovative ideas, practising humility, and following other rules for working in teams will help you become a more likeable leader. You’ll need a culture of success within your organization, one that includes out-of-the-box thinking.

6. Responsiveness

"Life is 10% what happens to you and 90% how you react to it." -Charles Swindoll

The best leaders are responsive to their customers, staff, investors, and prospects. Every stakeholder today is a potential viral spark plug  for better or for worse, and the winning leader is one who recognizes this and insists upon a culture of responsiveness. Whether the communication is email, voice mail, a note or a tweet, responding shows you care and gives your customers and colleagues a say, allowing them to make a positive impact on the organization.

7. Adaptability

"When you're finished changing, you're finished." - Ben Franklin

There has never been a faster-changing marketplace than the one we live in today. Leaders must be flexible in managing changing opportunities and challenges and nimble enough to pivot at the right moment. Stubbornness is no longer desirable to most organizations. Instead, humility and the willingness to adapt mark a great leader.

8. Passion

"The only way to do great work is to love the work you do." -Steve Jobs

Those who love what they do don’t have to work a day in their lives. People who are able to bring passion to their business have a remarkable advantage, as that passion is contagious to customers and colleagues alike. Finding and increasing your passion will absolutely affect your bottom line.

9. Surprise and Delight

"A true leader always keeps an element of surprise up his sleeve, which others cannot grasp but which keeps his public excited and breathless." - Charles de Gaulle

Most people like surprises in their day-to-day lives. Likeable leaders under promise and over deliver  assuring that customers and staff are surprised in a positive way. There are a plethora of ways to surprise without spending extra money - a smile, We all like to be delighted — surprise and delight create incredible word-of-mouth marketing opportunities.

10. Simplicity

"Less isn't more; just enough is more." - Milton Glaser

The world is more complex than ever before, and yet what customers often respond to best is simplicity — in design, form, and function. Taking complex projects, challenges, and ideas and distilling them to their simplest components allows customers, staff, and other stakeholders to better understand and buy into your vision. We humans all crave simplicity, and so today's leader must be focused and deliver simplicity.

11. Gratefulness

"I would maintain that thanks are the highest form of thought, and that gratitude is happiness doubled by wonder." - Gilbert Chesterton

Likeable leaders are ever grateful for the people who contribute to their opportunities and success. Being appreciative and saying thank you to mentors, customers, colleagues, and other stakeholders keeps leaders humble, appreciated, and well received. It also makes you feel great! Donor's Choose studied the value of a hand-written thank-you note, and actually found donors were 38% more likely to give a 2nd time if they got a hand-written note!

The Golden Rule: Above all else, treat others as you’d like to be treated

By showing others the same courtesy you expect from them, you will gain more respect from co-workers  customers, and business partners. Holding others in high regard demonstrates your company’s likeability and motivates others to work with you. This seems so simple, as do so many of these principles — and yet many people, too concerned with making money or getting by, fail to truly adopt these key concepts.

November 10, 2015


SQL Server 2016 introduces the new statement because it is very confusing when you need to check an object either it is present or not.

Previously when we need to check the Store procedure either it is exists or not we use following long lengthy syntax:

IF OBJECTPROPERTY(object_id('dbo.sp_GenerateReport'), N'IsProcedure') = 1
DROP PROCEDURE [dbo].[sp_GenerateReport]

Now in the latest version of SQL Server, they reduce the long lengthy statements into one line for Store procedure, function and tables. They named the statement as 'DIE' => DROP IF EXISTS


See that!!! this is so simple to remember and use in your daily routine queries.


October 29, 2015


1. Recite while Leaving Your House, And 70,000 Angels Will Protect You from All sides.

2. Recite On Entering Your Home, And Poverty Won't Enter Your Home.

3. Recite After Wuzu, And It Raises You 70 Times In Allah's Rank.

4. Recite Before Sleeping And 1 Angel Will Protect You The Whole Night.

5. Recite After Fard Salah And The Only Thing That Is Separating You From Paradise Is Death.

If you pass this on Its Sadqa-e-Jaria (meaning you on getting rewarded for it, every time someone one acts upon it even when you have died, up until the day of judgement).

October 26, 2015


    a. TEACHER
    b. PARENTS
    c. ELDERLY

    a. HONESTY
    b. FAITH

    c. DEBT

    a. TONGUE
    b. ANGER

    a. BAD DEEDS

    b. MANNERS
    c. PIETY

    a. BODY
    b. CLOTHES

    a. DEATH
    c. ADVICE

August 28, 2015

Custom Transpose In SQL Server

When we are playing with the database queries in order to create store procedure, triggers or job...we sometimes need to pass the comma separated string of integer values into the IN clause of SQL query.

Took the example from School where case is that we need to get the list of different Students based on StudentID provided in the procedure as a comma separated string.

DECLARE @StudentIdList AS VARCHAR(8000) = '1,10,15,18,22,45,99'

So when we try to get the Student List based on this parameter using the IN clause as:

SELECT StudentID, StudentName, RollNumber, Age
FROM   Student
WHERE  StudentID IN (@StudentIdList)

What happend!! when we try to run the above query. It will return the error on the IN parameter and mesage is mentioning that Cannot able to convert varchar to bigint....(something like that)

So how do we solve the problem???

Here comes the powerful transpose concept. Here we will create a function which will convert the comma separated string into the table structure where each value will be place into the rows.

CREATE FUNCTION [dbo].[ParamsToTable]
    @ParameterString VARCHAR(8000)
    DECLARE @SingleValue VARCHAR(10)

    WHILE LEN(@ParameterString) > 0
        SET @SingleValue = LEFT(@ParameterString, ISNULL(NULLIF(CHARINDEX(',', @ParameterString) -1, -1), LEN(@ParameterString)))
        SET @ParameterString = SUBSTRING(@ParameterString, ISNULL(NULLIF(CHARINDEX(',', @ParameterString), 0), LEN(@ParameterString)) + 1, LEN(@ParameterString))
        INSERT INTO @TblParam VALUES (@SingleValue)

Use the above created function in your sql query in order to generate the desire result as:

SELECT StudentID, StudentName, RollNumber, Age
FROM   Student
WHERE  StudentID IN (SELECT * FROM ParamsToTable(@StudentIdList))

The reason to put the query block into the function is that by doing this we can use it on several places where we need such type of activity to perform.

Let me know if you have any query over this implementation.


August 26, 2015

Recursion In LINQ

A method which called itself is called "Recursive". These methods are extensively used in daily programming practices. We use it to solve the complex problems or puzzles we face in code. Using recursion add needless complication in other programs.

Before jump into the LINQ world, let me tell you the method definition and implementation. The method should contain the reference variable parameter. It checks a condition near the top of its method body, as many recursive algorithms do.

So if you see the same method signature repeated many times in the call stack, you have a recursive method.

Back to topic, so how the we can acheive the recursion in LINQ query. It is good here to follow the example and write a LINQ query according to it.

Suppose I have list Candy. And each candy have different flavors while some flavor may extend to their child flavors. We need to calculate the 'Total Count' of candy flavors. How do we acheive this?

Diagram of this case is like this tree:

Candy --> Flavor1
Candy --> Flavor2 --> SubFlavor1 --> One, Two
Candy --> Flavor2 --> 
Candy --> Flavor2 --> SubFlavor1 --> Three --> Four, Six


We will use 'SelectMany' in order to calculate the 'Total Flavors' count. When we use 'SelectMany', it collapses many elements into a single collection. The code logic will be:

var flavorCount = candyList.SelectMany(sm => sm.Flavors).Count(); // C#

Dim flavorCount = candyList.SelectMany(Function(sm) sm.Flavors).Count() ' VB.NET

You see that!!! this is very simple in LINQ in order to count the 'Total Flavor'. Here I used 'SelectMany' in order to get the count. 

Let me know if have any queries left.


July 30, 2015

Updates In Visual Studio 2015

In the month of July, 2015... a major release annoucement being made for VS 2015 and .Net Framework 4.6. This post is intent to share with you the great updates which are available in this version.

1. ASP.NET Tooling Improvements:
    a. JSON Editor
    b. HTML Editor Updates
    c. JavaScript Editor Improvements
    d. ReactJS Editor Support
    e. Support for JavaScript package managers like Grunt, Gulp and Task Runners

2. ASP.NET 4.6 Runtime Improvements
    a. HTTP/2 Support
    b. Support for the .Net Compiler Platform
    c. Async Model Binding For Web Forms

3. ASP.NET 5

4. Entity Framework
    a. Entity Framework 6.x
    b. Entity Framework 7

This the summary of updates came in this release. In order to read these updates in detail please visit the blog of Scott Guthrie:

June 23, 2015

ERROR: MSDTC on server 'SomeServerName' is unavailable.

This exception is rise when you use 'TransactionScope' in your LINQ to SQL or LINQ to Entity logic where updating the database with multiple tables at once. Exception is belongs to 'System.Data.SqlClient.SqlException'. Exception is raised because of 'Distributed Transaction Coordinator' which not enabled or running on your server/machine.


We have three different types of methods available in order to fix the exception:

1. Check the firewall settings:

In Run, type firewall.cpl.
Click Exceptions Tab.
Click Add Program.
Browse for Msdtc.exe (normally found under C:\Windows\System32).
Click Add Port.
In the Add A Port window, give a name in the Name field.
Give 135 in the Port Number Field.
Select TCP.
Click OK.

2. Start via Services

Method A:
Find the service called 'Distributed Transaction Coordinator'.
RIGHT CLICK (on it and select) > Start.

Method B:

Type services.msc in the run command box
Select “Services” manager; Hit Enter
Select the service “Distributed Transaction Coordinator
Right on the service and choose “Start

3. Use this for windows Server 2008 r2

Click Start, click Run, type dcomcnfg and then click OK to open Component Services.
In the console tree, click to expand Component Services, click to expand Computers, click to expand My Computer, click to expand Distributed Transaction Coordinator and then click Local DTC.
Right click Local DTC and click Properties to display the Local DTC Properties dialog box.
Click the Security tab.
Check mark "Network DTC Access" checkbox.
Finally check mark "Allow Inbound" and "Allow Outbound" checkboxes.
Click Apply, OK.


We can check that either the 'Distributed Transaction Coordinator' is enabled or not. In LINQ to Entity, we use 'TransactionScope.Complete();' line at the end of transaction. Run the application using breakpoint and you can check that either this line is parsed successfully or raise error/exception. 

If it is parsed then it means 'Distributed Transaction Coordinator' is enabled successfully and if it is not try the other method mentioned above in the post.

Let me know if you face any exception after implementing the suggested methods.


January 7, 2015

WCF Project Templates in Visual Studio

Article is copying from my publish article at

Project templates provide the class structure and definition of service contracts, data contracts and other important features in Visual Studio for Windows Communication Foundation. Using these predefined template helps you to write a service with minimal code interaction and it will lead you to build more advanced services for your projects.

There are four different types of templates present in Visual Studio. The first two are the most commonly used to build, test and deploy SOA architectural applications.

1. WCF Service Library: 

The WCF Service Library project (C#) consists of three files; IService1.cs, Service1.cs and App.config. The WCF Service Library project (VB.Net) is consists of three files; IService1.vb, Service1.vb and App.config.

This type of project is suitable when we are focused on building the services first and deployment later.

  • IService File: This is the interface where the WCF service attributes are applied. In this file you place the definitions of data contract methods/operations.
  • Service File: This file is inherited from IService interface file and includes the implementations of defined interface's data contract methods/operations. 
  • Application Configuration File: In this file, you place the definitions of secure HTTP binding, endpoints of services and other important features.

2. WCF Service Application:
The WCF Service Application project (C#) is consists of four files; IService1.cs, Service1.svc, Service1.svc.cs and Web.config. The WCF Service Application project (VB.Net) is consists of four files; IService1.vb, Service1.svc, Service1.svc.vb and Web.config.

This type of project template creates a web site to be deployed to a virtual directory and hosts a service in that website.

  • Service Contract File (IService): The service contract interface file where you place the definitions of data contract operations.
  • Service Host File (Service1.svc) and Service Implemnetation File (Service1.svc.cs): This file is inherited from the service contract file and implements the data contract operations.
  • Web Configuration File: In this file, you place the definitions of secure HTTP binding, endpoints of services and other important features.

3. WCF Workflow Service Application:
The workflow (WF) service application can be accessed like a web service. It defines distinguish templates for XAML and other imperative programming models. We can create sequential and state machine workfow projects using these templates.

4. Syndication Service Application:

This type of project template provides the syndication functionality in an application in which you can easily work with feeds in ATOM, RSS and other custom formats as a WCF service. These are allowed you to read and create them and also expose them on service endpoints.

Now hopefully, you'll understand the different project templates in WCF which will be create as per the demand and the requirement.

January 6, 2015

Encryption - Decryption using AES Algorithm

Article is copying from my publish article at

You can find plenty of algorithms on the Internet that provide the Encryption - Decryption functionality. One of them is the AES algorithm. AES stands for "Advanced Encryption Standard".

The Advanced Encryption Standard was established by US National Institute of Standards and Technology in 2001. It was based; on the work of two Belgian cryptographers, Joan Daemen and Vincent Rijmen, who submitted the proposal to NIST during the selection process.

In the AES algorithm, there is a terminology we use called 'Cipher Mode'. There are different types Cipher Modes present in the algorithm. Based on your specific needs and requirements you can select the Cipher Modes. Let's have a look at what these are and how they differentiate from other cipher modes.

1. Electronic Code Book Mode: This mode doesn't require any feedback to be applied. You pass the plain text/data using this and and get the resulted Cipher data from it directly. The main disadvantage is that this mode will return the same cipher data on passing the same type of plain text in loop; if you pass 'Hello, World!' three times in this mode then it will return same cipher data in each iteration. That is why this mode is considered as 'Vulnerable' and not recommended for use.

2. Cipher Block Chaining Mode: This mode is required to add the feeback to modify the pre-encrypted data; with the feedback it will make each cipher data different from previous result. This mode is commonly used to secure applications.

3. Cipher Feedback Mode: This mode works like a Stream Cipher where data being processed can be shorter values rather than a larger block. In this mode, instead of passing the data to AES, it gets the XORed value that is generated from AES engine on the basis of previous message history. Here only XOR function is applied to the data and returns the smaller widths of data as compared to block size.

4. Output Feedback Mode: This mode is quite similar with Cipher Feedback Mode, but does not use the Stream Cipher due to the weakness when the data width that doesn't match the blocksize of encryption algorithm.

5. Counter Mode: This mode is also very common and used in to secure an application where count value of blocksized is maintained and encrypted using XOR. 

I'm going to use the C# Console Application in order to test AES algorithm different approaches. In this post I'm going to define two techniques of AES algorithm in order to Encrypt - Decrypt data.

1. First Technique: Using Aes Class which is inherited from SymmetricAlgorithm

Main Method:

const string original = "Here is some data to encrypt!";
Console.WriteLine("Data to encypt/decrypt: " + original + "\n");

Console.WriteLine("New Technique");

// Create a new instance of the Aes class. This generates a new key and initialization vector (IV)
using (var aes = Aes.Create())
    if (aes == null) return;
    // Encrypt the string to an array of bytes
    var encrypted = AesMode.NewEncryptMethod(original, aes.Key, aes.IV);

    // Decrypt the bytes to a string 
    var decrypted = AesMode.NewDecryptMethod(encrypted, aes.Key, aes.IV);

    //Display the encrypted data and the decrypted data
    Console.WriteLine("Encrypted: {0}", Convert.ToBase64String(encrypted));
    Console.WriteLine("Decrypted: {0}", decrypted);

Classes Used:

public static byte[] NewEncryptMethod(string plainText, byte[] key, byte[] iv)
    // Check arguments. 
    if (plainText == null || plainText.Length <= 0)
        throw new ArgumentNullException("plainText");
    if (key == null || key.Length <= 0)
        throw new ArgumentNullException("key");
    if (iv == null || iv.Length <= 0)
        throw new ArgumentNullException("key");
    byte[] encrypted = { };

    // Create an Aes object with the specified key and IV
    using (var aes = Aes.Create())
        if (aes == null) return encrypted;
        aes.Key = key;
        aes.IV = iv;

        // Create a decrytor to perform the stream transform.
        var encryptor = aes.CreateEncryptor(aes.Key, aes.IV);

        // Create the streams used for encryption. 
        using (var msEncrypt = new MemoryStream())
            using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                using (var swEncrypt = new StreamWriter(csEncrypt))
                    //Write all data to the stream.

                encrypted = msEncrypt.ToArray();

    // Return the encrypted bytes from the memory stream. 
    return encrypted;

public static string NewDecryptMethod(byte[] cipherText, byte[] key, byte[] iv)
    // Check arguments. 
    if (cipherText == null || cipherText.Length <= 0)
        throw new ArgumentNullException("cipherText");
    if (key == null || key.Length <= 0)
        throw new ArgumentNullException("key");
    if (iv == null || iv.Length <= 0)
        throw new ArgumentNullException("key");

    // Declare the string used to hold 
    // the decrypted text. 
    string plainText;

    // Create an Aes object 
    // with the specified key and IV. 
    using (var aes = Aes.Create())
        if (aes == null) return null;
        aes.Key = key;
        aes.IV = iv;

        // Create a decrytor to perform the stream transform.
        var decryptor = aes.CreateDecryptor(aes.Key, aes.IV);

        // Create the streams used for decryption. 
        using (var msDecrypt = new MemoryStream(cipherText))
            using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
                using (var srDecrypt = new StreamReader(csDecrypt))
                    // Read the decrypted bytes from the decrypting stream and place them in a string
                    plainText = srDecrypt.ReadToEnd();

    return plainText;

2. Second Technique: Using Cipher Mode "ECB" and a priavate key

Main Method:

const string original = "Here is some data to encrypt!";
Console.WriteLine("Data to encypt/decrypt: " + original + "\n");

Console.WriteLine("\nOld Technique");

var encryptData = AesMode.OldEncryptMethod(original);
var decryptData = AesMode.OldDecryptMethod(encryptData);

//Display the encrypted data and the decrypted data
Console.WriteLine("Encrypted: {0}", encryptData);
Console.WriteLine("Decrypted: {0}", decryptData);

Classes Used:

// A key used to encode and later decode the data
private const string PrivateKey = "@pRiVaTeKeY123";

/// <summary>
/// OldEncryptMethod
/// </summary>
/// <param name="plainData">Contains plain data to encrypt</param>
/// <returns>Encrypt Data</returns>
public static string OldEncryptMethod(string plainData)
    byte[] result;
    var utf8Encoding = new UTF8Encoding();
    var hashProvider = new MD5CryptoServiceProvider();
    var tDesKey = hashProvider.ComputeHash(utf8Encoding.GetBytes(PrivateKey));
    var tDesAlgorithm = new TripleDESCryptoServiceProvider
        Key = tDesKey,
        Mode = CipherMode.ECB,
        Padding = PaddingMode.PKCS7

    var dataToEncrypt = utf8Encoding.GetBytes(plainData);

        var encryptor = tDesAlgorithm.CreateEncryptor();
        result = encryptor.TransformFinalBlock(dataToEncrypt, 0, dataToEncrypt.Length);

    return Convert.ToBase64String(result);

/// <summary>
/// OldDecryptMethod
/// </summary>
/// <param name="encryptData">Contains encrypt data to decrypt</param>
/// <returns>Decrypt Data</returns>
public static string OldDecryptMethod(string encryptData)
    byte[] results;
    var utf8Encoding = new UTF8Encoding();
    var hashProvider = new MD5CryptoServiceProvider();
    var tDesKey = hashProvider.ComputeHash(utf8Encoding.GetBytes(PrivateKey));
    var tDesAlgorithm = new TripleDESCryptoServiceProvider
        Key = tDesKey,
        Mode = CipherMode.ECB,
        Padding = PaddingMode.PKCS7

    var dataToDecrypt = Convert.FromBase64String(encryptData);

        var decryptor = tDesAlgorithm.CreateDecryptor();
        results = decryptor.TransformFinalBlock(dataToDecrypt, 0, dataToDecrypt.Length);

    return utf8Encoding.GetString(results);

Hope it helps you to perform your action in fast pace. Stay tuned!