Chander Dhall's Blog



Why I love Discountasp.Net?

Always ahead of the game

Long back when I started looking for .NET 4.0 hosting, I was very surprised to see that had support for it. This is way before any other hosting I knew at that time supported .NET 4.0. The same happened when I wanted hosting support for Node.js on the Windows Platform. Guess what, had it. I even remember asking them a question about deployment where they helped me to an extent of fixing my web.config (which was obviously my problem not theirs). Not only the support was quick, they owned the problem, fixed it and didn't even complain that it's my problem. For $10-20 a month this was unbelievable for me and I turned a fan overnight. Don't be surprised when I tell yo that they are supporting WebSockets too.


We are developers and we love control. Perhaps is the only one on Microsoft platform that gives you a great amount of control. Their control panel has cool functionality - start/stop website, recycle app pool. They also support IIS Manager. Just to let you know the experience of a fellow developer - "IIS tools at are easier to use than the regular IIS installed on your server". That says a lot. I love the flexibility they give you given it's a shared hosting environment. I remember how much time I save now than having to go talk to a Tech Support rep at my previous cheap hosting company :).


This was the most seamless of all database options I have used in shared hosting environment. I could connect via Sql Server Management Studio and use it as I am using my real database. Compared to the previous hosting provider I used, I could chose an add-on of my choice, I was able to upgrade from Sql Server 2008 to 2012 very easily (which btw was not even an option with the previous provider. They wouldn't support 2012). They have an Attach MDF File tool that is awesome. And they support SSL encrypted SQL connections.

Staging done Right

SnappHQ.Com has a new product from Guess what, Go from Staging to Production in just one click. Yes, that's right and what's more awesome? They are actually offering it free. Till when? Not sure, however I signed up at a good time. Hope you take the advantage too :).

Some other cool features:
  • Speed

    I checked the load time of the my website from my previous hosting provider vs site loaded much faster. They also let you do a Monthly data transfer of 80 Gb. Guess What? Planning to move my podcast Chander Tech Podcast
  • Isolated App Pool

    Each website is hosted in an isolated App Pool and they support full trust.

.NET Community supporters

This is probably the best reason I will chose over anyone else. There are people who promise and then deliver. delivers even without promise. They are always out there supporting the community, taking the feedback and then applying it really well and enhancing their products. Snapp is a great example. It came up after discussion with devs and they put in a lot of investment both time and money and created an offering for the community. We all know that is one of the first ones to sponsor any user group and has offered Generous Free 6-month hosting plans to attendees. I remember distributing about 600 of those at last year. I actually ran into the staff at a code camp in San Diego so it was nice to catch up with them. I know they provide free hosting for .NET user groups and events so if you are organizing one, you should contact them about this.

Special Thanks

We recently launched Chander Tech Podcast. and had more than 10k downloads in just 3 days. guys happened to listen to the podcast and they approached me to sponsor the podcast as they realized that the content was helpful for the community and they wanted to encourage initiatives like this. Michael Ossou of also invited me to his webcast series recently and Takeshi Eto and Frank Cheung have done a great job taking the developer feedback that I've given to them over a period of time and implement it to make great products.

Microsoft Sql Server driver for Nodejs - Part 2

Nodejs, Sql server and Json response with Rest

This post is part 2 of Microsoft Sql Server driver for Node js.In this post we will look at the JSON responses from the Microsoft Sql Server driver for Node js.


  • If you have read the Part 1 of the series, you should be good.
  • We will be using a framework for Rest within Nodejs - Restify, but that would need no prior learning.


Restify is a simple node module for building RESTful services. It is slimmer than Express. Express is a complete module that has all what you need to create a full-blown browser app. However, Restify does not have additional overhead of templating, rendering etc that would be needed if your app has views. So, as the name suggests it's an awesome framework for building RESTful services and is very light-weight.

Set up - You can continue with the same directory or project structure we had in the previous post, or can start a new one. Install restify using npm and you are good to go.

Go to Server.js and include Restify in your solution. Then create the server object using restify.CreateServer() - SLICK - ha?

Then make sure you provide a port for the Server to listen at. The call back function is optional but helps you for debugging purposes.

Once you are done, save the file and then go to the command prompt and hit 'node server.js' and you should see the following:

 Server Running

To test the server, go to your browser and type the address 'http://localhost:8080/' and oops you will see an error.

 Server error

Why is that? - Well because we haven't defined any routes. Let's go ahead and create a route. To begin with I'd like to return whatever is typed in the url after my name and the following code should do it.

You can also avoid writing call backs inline. Something like this.

Now if you go ahead and type http://localhost:8080/ChanderDhall/LovesNode you will get the response 'Chander Dhall loves node'.

NOTE: Make sure your url has the right case as it's case-sensitive. You could have also typed it in as 'server.get('/chanderdhall/:name', respond);'

Stored procedure:

We've talked a lot about Restify now, but keep in mind the post is about being able to use Sql server with Node and return JSON.

To see this in action, let's go ahead and create another route to a list of Employees from a stored procedure.

The following code will return a JSON response. 

Again run the server using 'node server.js' and you are good to go. Now you can use the browser or fiddler or curl it if you like and once you go to - 'http://localhost:8080/Employees' the fiddler response is below.

  Fiddler Response

Elegant Coding tip

Question: This sounds good. But I don't like the way I have to loop through and create the array with hardcoded values.

Answer: That's right. I am going to discuss what can be done differently to get a better output.

Source Code: I looked at the source code and found out that Microsoft passes back the results object which has two properties: 'meta' and 'rows'. Note: I could have done that without looking at the source code, too but it's just me.

'meta' as the name suggests gives you metadata regarding what is returned back to you. This includes the following: name, nullable, size and type information about the column. For example, name = id, nullable = True, size = 10, type = number.

'rows' returns the array of values from the database. rows = { [1, Chander Dhall], [2, Adi Dhall]};

So, this little coding snippet would help you not having to hard code values like 'id' and 'lastName'.

This gives us the nicely formatter JSON, with the names of database columns paired with value from the database.

Counter Argument : Since we are creating JSON values so why worry about this? Why not just send what we are getting from the database (also JSON) to the app?

Answer: Yes, you could. But I would not do that for two simple reasons:

1. The payload increases. In my case, the payload was 3 times more than what it was with the formatter JSON. was with the formatter JSON.

2. Also, I don't want the app to know the specific metadata regarding my properties.

What else can be done? May be create a formatter or may be even come up with a hypermedia type but that may upset some pragmatists. Well, that's going to be a totally different discussion and is really not part of this series.


We've discussed how to execute a stored procedure using Microsoft Sql Server driver for Node. Also, we have discussed how to format and send out a clean JSON to the app calling this API.

You can find Chander Dhall on Google+ and Twitter

Email Chander Dhall

Microsoft Sql Server driver for Nodejs
Microsoft released the most awaited version of it's Sql Server driver for Nodejs. I have a detailed series of articles describing how to use it here.
Get Started with Visual Studio 11
I just started a series of blog posts on the cool new features of Visual Studio 11.

You can find these posts here:

Have Chander Dhall speak at your event/user group?
INETA Community Speakers Program
Chicago Code Camp Video

This May 14, I had a great time at Chicago Code Camp. Thanks to the organizing team to have organized the event really well.

It was great to meet Microsoft MVP David Giard who I am thankful to have given me the opportunity to speak at his poular TV show.

The Video  is available at his website here. Looks like I need to start speaking little slowly. This Video talks about SOLID principles which was just a small part of my talk.

However, please let me know your comments about it and I'd be more than willing to reply back to your suggestions. here's my email 

Upcoming great events.

 All you all know that Dallas day of dot net is the new big event coming in Dallas. For more information please visit or

 If you are in Austin, Brandon Satrom has done a great job putting together this event. 

If you’re near Austin, TX or Chicago, IL, you’ll want to join us for a special two-day Web Camp. We’ll cover ASP.NET MVC in-depth on day one and help you get hands-on on day two, facilitating smaller groups through labs, live-coding exercises, or even collaborating on your apps! If you can’t make a two-day event, never fear! We have a series of one-day camps in March, April, May and June throughout the region.

Registration could be done here.

Day 1 -

Day 2 –


For more information please visit Brandon's blog.!.aspx


Again, In Dallas area Chris Koenig is putting together 2 great boot camps. Don't miss them. 


You are invited to join your local Microsoft® Developer Evangelists for an inside look at Windows Azure™ and Windows® 7.

No matter whether you are interested in building a solution for the cloud or exploring how to maximize your impact on Windows Client, these MSDN® Boot Camps are the perfect opportunity to get the hands-on experience to 'unleash your coding genius'.

So bring your questions, laptop, and get in the know with these dynamic topics. Learn more about each boot camp along with the dates and cities below.

MSDN Events Presents: Windows Azure 2-Day Boot Camp

The cloud is here. Time to strap your boots on and wade in. We have worked to bring the region's best Azure experts together to help you reach your full potential in the cloud. This 2-day deep dive program will prepare you to deliver solutions on the Windows Azure Platform.

Each day will be filled with training, discussion, reviewing real scenarios, and hands-on labs. The primary areas of focus will include: An Intro to Cloud Computing and Azure, Web Roles, Messages and Queues, Using Azure Tables, Using BLOB Storage, Worker Roles, Diagnostics and Service Management, SQL Azure™, Connecting with AppFabric, Cloud Computing Scenarios and Available Resources.

We highly recommend all attendees bring a laptop in order to gain the full experience from this boot camp. The download tools can be found on the registration pages for each event and will be sent in an email prior to the event.

Ready to get started? To register, click on the city found in the column to the right. For a complete list of all cities, visit or

MSDN Events Presents: For the Win: Windows 7 Development Boot Camp

Web and cloud may be all the rage, but many developers are still doing hardcore client development. If you are among them, this Boot Camp is for you! In this full-day event, we will explore how to maximize your impact on the Windows client.

Our interactive sessions will include topics from throughout the Windows development platform. We will look at application compatibility and transitioning your applications to Windows 7, integrating with the Windows taskbar, developing for IE9, utilizing the cool functionality in the Sensors and Location Platform so that your application better responds to its current environment, leveraging the multi-touch capabilities (especially in kiosk scenarios), and creating Silverlight® 4 out of browser applications.

This event is a unique opportunity, partnering classroom learning with hands-on-labs and leveraging experts to advise you so we can help you "win" with Windows 7. We highly recommend all attendees bring a laptop in order to gain the full experience from this boot camp. The download tools can be found on the registration pages for each event and in an email prior to the event.

Ready to get started? To register, click on the city found in the column to the right. For a complete list of all cities, visit or



Strategy Pattern Using Delegates (Func)- presentation on Dec 14, 2010

 Strategy Pattern using Func
An alternative to using Strategy pattern using interfaces is Strategy Pattern using delegates.

    •    Create a class with all the different strategies.

 public class Calculator
       public static int Add(int num1, int num2)
           return num1 + num2;

       public static int Subtract(int num1, int num2)
           return num1 - num2;

       public static int Multiply(int num1, int num2)
           return num1 * num2;

       public static int Divide(int num1, int num2)
           return num1 / num2;


    •    Test the code.
int a = 100;
            int b = 50;

            Func<int, int, int> calculate = Calculator.Add;
            int sum = calculate(100, 50);

            calculate = Calculator.Subtract;
            int difference = calculate(100, 50);

            calculate = Calculator.Multiply;
            int product = calculate(100, 50);

If you are new to the syntax, Func. Func is like a delegate that in the above case takes the first two ints as input and outputs the int (third).
Another cool way of using Func is using lambda expressions.

  Func<int, int, int> calculate;
   calculate = (x, s) => x + s;

We could do the above in a single line itself. But what it means is changing the strategly on the fly. Func is a pretty cool feature that reduces a lot of the delegate code we had to write in .NET 2.0. Happy coding !

Strategy Pattern - presentation on Dec 14, 2010
Content Missing!
Dallas day of dot net
We are putting together a great conference together at Microsoft Conference in Dallas. It's Dallas Day of Dot Net.

We have 3 different tracks. Beginners' track which is more hands on, intermediate track and expert track We plan to incorporate the hottest dot net topics for discussion.

Ayende is flying in from Tel Aviv. Our speakers include 3 from Microsoft, 2 authors, 4 open source contributors, 5 MVPs, 3 architects and the list is growing. 55% of the registrants as of now are from outside the state. I will keep updating from time to time.

You can use 'ChanderDhall' as the discount code Thus is an additional discount code over the early bird discount code. All proceeds go towards a cancer patient For more information contact

Thanks to our sponsors:
Matrix's Dallas Day of dot net's main sponsors. Platinum sponsors also include Telerik and DevExpress. Caffeine sponsors: Comsys. Volunteer Gift Sponsors: TekSystems. Golds Sponsors: Head Spring Systems and ITalent. Gift sponsors: Oreilly and Pluralsight.

If you'd like to sponsor the event please email
More Posts Next page »