Solving the problem is the interesting part, providing finishing touches – not so much. What to do?

Developers are usually problem solvers, we solve problems and once we solve the core of it we have a tendency to call it done. However completing the rest of it, the finishing touches takes a looong time.
The 99% complete syndrome is a documented fact that aligns well with software development and developers.

I have noticed this in many people and not all are developers. Once they solve the hard part, rest of them is unexciting/boring/tiring to them. Do not get me wrong, that remaining part is also as equally important in a process of making a thing complete, but the drive is usually gone. I am guilty of this too, once I am done solving that’s challenging, solving that was new and interesting, the drive, the motivation slightly decreases.
Why is that? How do you stay motivated and driven to complete it completely?

This can really happen if you are working on a side gig, Once a thing is 99% complete and 1% incomplete.
Deep inside my heart, I wish that was it. I know it is not and I know I will eventually do the rest of it, but when is that eventually going to come? I do not know.
I also noticed that, if you are working in an office or a product driven by other people you may still have this feeling but then there is someone at your shoulders waiting for it to be completely complete and so you complete it. There you go, nagging works ūüôā

I do not want to include everyone here, I know developers who will completely complete the product before saying its DONE, done whether its office or a project they do in their garage. I am proud of those guys and one can really learn from those guys. I hope you have seen or met some of these guys around you too.
Its good to have them around.

Here is what I do to keep me going on my side gigs in those times,

  • Try and set deadlines, real deadlines, the one that goes on the calendar.
    • Share deadlines with your close ones who keep you motivated.
  • Demo the product to people who can be nit picky.
    • Being nit picky is good. It leads you to become a perfectionist.,which is good. Most times.
  • If you have a TODO list, DO NOT check the item until is completely complete.
    • If you do not have it, have one. TODAY.
  • Credit yourself after completely completing it.

What do you do to stay motivated and driven after 99% completeness? I would love to hear

Interviewing: The other side of the table.

Hey Friends,

It’s been a while since I have made a post, I have a lot to write but I have been bit busy with work, family, friends and some side projects. Today I want to dedicate this post to “Interviewing“.

In my new job I have been given an opportunity to interview people for various roles. Not sure about you, but I still have memories of my interviews (all good and bad, stupid and smart) and therefore I know what it’s like to give a technical interview for a job and now I know what it’s like to take one. I feel I shall share my early experience with you. I have not counted them all but I have taken some tech interviews till now and overall I feel, I have collected some knowledge that I can share with you guys.

While all this is good and I feel esteemed to do so, It’s also bit of a concern, specially when I know that the person I am interviewing has twice the experience I have and sometimes is going to be designated a role higher than me. I mean, what do you ask a candidate like that? Are my questions going to be too easy for them? And this sometimes apply to guys whose resume and projects looks outstanding. So after some early experience for me It turns out that it does not matter. If your questions are reasonably sound and tests basic knowledge, you can test the deverloper/problem solver in them. I have had people from fortune 500 companies do massive blunders when they write code on board and yes I have had people write error free compilable code on white board for the same questions. No, the questions were not given from “Crack the coding interview” or similar :). Sometimes I see someone making mistakes that I made or may be still make and sometimes I see a totally different approach that I didn’t thought of and it gladly surprises me. I have also had some bad interviewers interview me and I try not to be one myself during the interview.

The point is, If in your job, you are trusted to interview some one, feel proud, feel glad that you are given an opportunity like that but prepare/spend some time thinking about your questions and knowing about the person. In an interview you sort of are the representative of the company to that person, It becomes your duty to give the best of yourself, they do not know the company yet, but your approximate forty five minutes with them can give a general sense of type of people working in your company.

In all, I feel every developer should get a chance to interview other people in course of their career, Doing it the right way can give you insights about your mistakes in the interview and it also gives you a chance to represent the name on the door that you walk in every morning, five days a week.

Share your experience and stories in the comments.
Happy Coding.

New Year, New Things, again.

Happy New Year friends,

2013 passed in blink of an eye and it was an amazing year for me. 2014 on the other hand brings so many new things in life. Before I go on about 2014, I would like to mention a few highlights about 2013.

Of Course the highlight of 2013 was that I got married to my girl friend and had an awesome time with family in India, but on the other hand I left Polaris Library Systems and snowy Syracuse, NY in Nov’13 and moved to sunny Mountain View, CA to work for a company called Adara Media.

2014, brings new challenges to me personally and professionally. Professionally- being a .Net nerd for so long, now I have decided to work in a “non windows” environment here in CA where I will be doing Java, MySql on a Mac instead of working with .Net, Sql Server, on Windows machine. This is not only just a technology change for me but an idea to widen my scope of technology that I can grasp and make better software on. Why did I do that? The heart wants what the heart wants…

Personally- Leaving Syracuse wasn’t easy, I have lived there for 4 years, had my masters there and worked in a company with awesome people making awesome software, It will always be a part of my life and in 2014 I will do my best to make this new place my new home.

Look forward to my upcoming posts, Happy coding.

Setup SingalR self-host in SSL

Hi Guys,

There has been a lot of buzz about singalR lately and If you havent checked it out yet, singalR is a fantastic realtime communication system, you should give it a go.

For friends who have played around with singalR and tried singalR self host and want to host in SSL, read on.

Setting up singalR in SSL is relatively very easy but not straight forward, I did not find it in documentation that this is the way to do it.
So here is my own.

Steps to create and host a signalR package in SSL

1)Get singalR self-host running, for help and quick start install nuget owin package

Install-Package Microsoft.Owin.Hosting -pre
Install-Package Microsoft.Owin.Host.HttpListener -pre
Install-Package Microsoft.AspNet.SignalR.Owin

Lets set up singalR on http://localhost:8082

static void Main(string[] args)
            string url = "http://localhost:8082";
            using (WebApplication.Start<Startup>(url))
                Console.WriteLine("Server started URL "+url);


    class Startup
        public void Configuration(IAppBuilder app)
            // to turn on cross domain and other stuff
            var config = new HubConfiguration { EnableCrossDomain = true, EnableJavaScriptProxies = true, EnableDetailedErrors = true };


After successfully doing it you can navigate to http://localhost:8082/singalr/hubs and you will see your dynamically generated hubs file.

so at the moment we have it running on localhost on *non* SSL environment.


To run it in SSL, you need an SSL certificate. Two things to note here

1) SSL is port 443 or your ip address(localhost)

2) SSL needs a certificate (I am not going into detail about creating an SSL certificate but you can find it here)

But wait, we have hosted our singalR at socket address= localhost:8082, How is it going to map at port 443 then?

It wont. When you set up an SSL it will map to socket address = localhost:443 (because of point 1)


To make it work you need a SSL certificate (a self signed will do) for your localhost and a *unique* url to host singalR

so after creating a SSL certificate i have changed the above mentioned code to

static void Main(string[] args)
            string url = "https://localhost/server1/";
            using (WebApplication.Start<Startup>(url))
                Console.WriteLine("Server started URL "+url);

now if you navigate to https://localhost/server1/singalr/hubs you will see a dynamically generated file.

What does this tell me?

It tells me that I have hosted my signalr on https://localhost:443/server1/

But I have not enabled any port sharing, how does this work?

IIS automatically enables port sharing, and so does singalR. You can host as many server on SSL on a singal ip address/domain name

Note: if you have a domain name for your localhost you can use that too for example,

You can point your localhost/ address to a domain name in your host file.


Simple and quick, Hopefully this will help someone start easy.

Linq and Automapper, A View Model and Data Model binding solution. Part 2

Hey Guys, So finally I have got a second piece of my earlier post. However this isn’t going to anything about Linq. We have already seen in part 1 how we can use Linq classes as data model classes. We have also seen how Automapper can help bind th…

Hey Guys,

So finally I have got a second piece of my earlier post. However this isn’t going to anything about Linq. We have already seen in part 1 how we can use Linq classes as data model classes. We have also seen how Automapper can help bind those data models to my view models in an MVC application. This post will be more about getting closer to real scenario where often your view model and data model are not always so similar that you can not get away with magic of Automapper without tweaking it. The goal of this post is to determine if Automapper is fast enough when mapping is complicated and when automapper has to be configured to map objects correctly.

For variety purposes this demo will be for a C# console application. I am using the new Visual Studio 2012 and .Net 4.5. I have also got Automapper as usual from my Nuget package manager. So here is how my data model and view model looks like. Take a peek.





You can see there are bunch of difference between view model and data model classes:

  • The view model has string address while the data model has a seperate class CustomerAddressDataModel, it it is a member of CustomerDataModel
  • The view model has CompleteName and data model has FirstName and LastName
  • The view model has string IsMember while data model has boolean IsMember
  • The view model has CustomerCode while data model does not have any such thing.

So here if you try to map the above data model and view model. Automapper will blow. It will fail because it does not know how to resolve these issues. I will give a little idea but will not get into too much detail about how to configure Automapper to do so. I will attach the source code with this post for an enthusiast to play with it.

The following code will configure my automapper to resolve the above mentioned differences and successfully map my data model to my view model (or list of those). I have used value resolvers to resolve the data type issue, create CustomerCode attribute for view model. I have mapped address string by combining various values from data model’s member class. One can also achevie the similar result by creating another value resolver for address. Similarly the FirstName and LastName are combined to do get CompleteName, super easy.


Similarly to compare the mapping of Automapper, I also have Manual mapper in my MappingManager class. I wrote a simple Test method to spit out the time intervals and the mapped view model. Here is the code and the output.




The test method is a generic test method. It does both Automapper mapping and Manual mapping and it does it for the specified count of data models. Currently it does one data model to view model mapping and prints on the console. You can see it maps correctly which means our configuration of Automapper is correct.

Till now we can conclude two things. Complex mapping can be achieved by Automapper. The mapping we did includes type casting, flattening, creating derived attributes. Also we see that it is about 0.048 seconds slower for one mapping, which is not a big deal,¬†usually. Also I would like to point ¬†that Automapper always take a bit (in milliseconds) in first mapping more than its usual. Let’s compare as we did before, converting 100,000 data models to view models and see side by side comparision before we conclude any more.




So here we can see that for upto 1000 model mappings Automapper is not far behind and we hardly map more than 1000 models at one shot. What we see here is a very similar result to my part 1’s result of simple data model to view model mapping. This means Automapper has it’s consistency. Complex binding or simple binding, Automapper is a good tool to use and save time from mapping code, provided you can afford 100th second delay. Usually that’s not a problem Hence our goal: “determine if Automapper is fast enough when mapping is complicated and when Automapper has to be configured to map objects correctly”¬† is accomplished and we can say that Automaper is great mapping and time saving tool.

It passes my tests, I hope it does your’s too. Take care.


Source Code (Visual studio 2012, .Net 4.5 solution. You might need to convert dlls if you are using other versions)

Virtual Channels – More awesome than you think

Hey there, Recently I came across some really interesting thing called “Virtual Channels”. I had no idea what they are. As it turns out they are some pretty nice though, difficult feature given by Microsoft to do stuff when you do Remote Desktop C…

Hey there,

Recently I came across some really interesting thing called “Virtual Channels”. I had no idea what they are. As it turns out they are some pretty nice though, difficult feature given by Microsoft to do stuff when you do Remote Desktop Connection to some other computer. Once you figure out how does it work, it can be a pretty neat implementation.

Ever wonder what happens when you do Ctrl+C in one computer and Ctrl+V in another computer while you are in Remote Desktop Connection how does it just works? How it basically copies data from one user space in one computer and pastes into another? Obviously there is some sort of connection. Enter Virtual Channels.

According to msdn: “Virtual channels¬†are software extensions that can be used to add functional enhancements to a Remote Desktop Services application. Examples of functional enhancements might include: support for special types of hardware, audio, or other additions to the core functionality provided by the Remote Desktop Services¬†Remote Desktop Protocol¬†(RDP). The RDP protocol provides multiplexed management of multiple virtual channels.

This is very interesting to me. It means I can make my desktop app host it on one server(probably Terminal Server) and let the client computer RDP into my host/server computer and access the app/software from there. Since each user has its own user space and separate Virtual Channel there wont be any problems when multiple clients would connect to my server via Remote Desktop Connection.

If you are wondering what is this? Or want to learn about Virtual Channels here are some links that were helpful to me while understanding Virtual Channels.

Lets take an example, Let’s assume there is a software hosted on such a computer and everyone RDP’s into it. Now let’s say this software is supposed to print receipts, obviously the receipt printer has be on the client computer, what are the ideas of implementing this?

Sure you can have a web service, tcp connection etc. but that requires opening ports into your clients firewall, which may or may not be acceptable. One of the option is Virtual Channel or Dynamic Virtual Channel, msdn provides great explanation on what are those.

There is one particularly great example about Virtual Channel. Here is the link

This is very old yet beautiful example. The code attached in the above URL is for older visual studio and older Terminal Server. While I started from this I updated the code to work for Visual studio 2010 and Windows Server 2008 R2. It does not work if you convert your project into Visual Studio 2010 project. I have gone through the pain so you don’t have to ūüôā

Apparently Posterous does not allow me to upload zip files. That is the reason i posted alternative for uploading zip files in posterous blog before this one.

However you can access the folder form this link

This is a great starting point for anyone coding for Terminal Server using Dynamic Virtual Channels.

Here are couple of things that I discovered and could be helpful.

  • The client plug-in has to be of the same bitness(x86/x64) of the mstsc.exe on the client (RDP executable)
  • It helps if it’s Unicode
  • The above URL mentions the use of support dll while doing regsvr32, since you are using new Visual studio you will need updated support dlls, you can find them at

C:Program Files (x86)Microsoft Visual Studio 10.0VCredistDebug_NonRedistx86Microsoft.VC100.DebugCRT (of course it is x86/x64, debug/release according to your configuration)

Other details are dependent on what you want to do with Virtual Channels.

I hope this is helpful to you. In case you have any questions let me know.

Keep coding, later!

How to upload .Zip files in Posterous Blog

Hey there, So I was writing a post and I found out Posterous do not allow me to add zip files in the blog. This is very weird for a blogging website to me. Anyway, being an Engineer helps finding a solution. This is an era of cloud, you get tons o…

Hey there,

So I was writing a post and I found out Posterous do not allow me to add zip files in the blog. This is very weird for a blogging website to me. Anyway, being an Engineer helps finding a solution.

This is an era of cloud, you get tons of cloud space from Google, Microsoft, Amazon, Dropbox, SugarSync, Box etc. The all provide public and private sharing.

I figure why not make a public folder to any of these clouds and give you the link. Simple.

I choose Google drive just coz I like it.


  1. Create a folder in Google Drive or your choice of cloud.
  2. Share it publicly or anyone with the link
  3. For sake of organizing stuff, I have a separate folder for each blog that needs a zip file since they are child folders of my main shared folder they are automatically shared.
  4. After I upload I get can get a public access link like this






  1. After that, I copy the link and link it here. I have just linked a document but you can link anything, a zip folder will be the obvious choice since Posterous does not allow it.
  2. That’s it. I am now going to continue to my other blog and use this technique there ūüėõ

There is always a way around..


Hope this helps,



Linq and Automapper, A View Model and Data Model binding solution. Part – 1

Hi there, Hope you are doing great, I have another topic I would like to discuss with you! It’s Automapper. You may have heard of it and you may have already used it but I think there will be a little take away for everyone in this post. This will…

Hi there,

Hope you are doing great, I have another topic I would like to discuss with you! It’s Automapper. You may have heard of it and you may have already used it but I think there will be a little take away for everyone in this post. This will be the first part of the post

Today we are going to talk about:

1) How we can use Visual studio Nuget to get Automapper in our MVC 3 solution.

2) How we can map out LINQ data classes ( I will call them Data Model classes ) and bind them using Automapper.

3) Discuss how efficient and beneficial Automapper is than manual mapping.

However this first part will only consist of basic scenario. A basic mapping of Data Model classes to View Model which will be used by our views. The idea is to familiarize¬†and know Automapper before we start unleashing all it’s powers.

Let’s start with Nuget. Nuget is a God send to me. I have had the pain of manually adding references, dll, scripts and css, setting dependencies to .Net project for a simple solution that is provided by a third party tool. Nuget makes all that as simple as few clicks. It’s a “Package Manager” that now ships with Visual studio 2010. You can add thousands of third party tool without all the hassle by searching in it’s console, It will automatically set references, dependencies and what not. You can learn more about Nuget here.

So I used Nuget to find Automapper. Let’s discuss a little bit about Automapper.

Automapper is a object to object mapper. You can potentially map any object to any other object easily via this Automapper library. I personally use to map my Data Model to View Model and vice versa.

Why? Because Automapper takes care of my unproductive coding where I just write redundant code of mapping View and Data Models, It automatically does it for me at fairly low cost. Yes! A few configurations and we are done! Just give Automapper your input model and gives you your desired output model. For complete details see this.

I like to use LINQ to query my SQL database in my MVC solution. So for testing purposes I created this database dragged tables to my LINQ file which automatically created Data Classes for me. These classes look fairly like my model but I don’t want to use them as my View Model ofcourse… So Let’s create a basic Customer Model (View Model). Here is how it looks.


Fairly simple. Fairly similar to my Data Model Class. For part 1 let’s keep it that way for now.

Now I have installed Automapper but haven’t done anything with it yet. Let’s do it.

I have created a Folder “Data Context” where I keep my .dbml file and I have created a static class called “Mapping“. Mapping because it’s going to perform mapping via Automapper and static because it will be common for all the sessions.

Here is how it looks.


There are three methods,

Customer_ViewModelToDataModel() -> It calls Mapper (Autmapper’s class) .CreateMap takes in two template types, since it’s View Model-> Data Model binding the first argument is Input(View Model) and second argument is desired output type which is DataContent.Customer our LINQ Customer class. Based on relationships in Database, LINQ created a Transcation member in Customer class which is not present in out View Model “Customer ” class hence we perform an “Ignore” to leave that member out of the mapping.

Thats it. Automapper created a map for us. We don’t even have to specify which members map to which in each models.. Cool isn’t it.

Similarly we do Data Model -> View Model, since View Model’s Customer class does not have a “Transaction” member there is nothing to ignore in it. We have created another map.

The third function PerformMapping just wraps these methods so we can call them together.

Now, the application needs to know about this mapping before anyone tries to map one object to another. Since this is web project the best place to call our “PerformMapping” function will be Global.asax. Here is what I do there.


This is it. Your application knows that there is a map and these objects can be converted into one another via Automapper, but wait how to actually do that?

Here is how. I have created a view strongly typed with my View Model Customer. I will let MVC generate fields for me and this is what it gave me. Now we will perform simple insertion in DB for this posted View Model, we will convert this into Data Model Customer obect that LINQ recognizes and perform and insertion into a DB. So here are the snapshot for these steps


Notice I now use Mapper.Map instead of CreateMap, the templated parameters remain the same, the first one my input object, second one my output object but here i pass a object as a parameter so that Automapper can read from this object and write it to my desired object and give me back..

You would want to see that Model inserted don’t you.. Let’s generate another view called Show Customer which will fetch this view out, Only this time we will use Automapper to convert our Data Model LINQ Customer class to our View Model Customer class and pass that along in the View so that our view can display that. Here is a method that does that. Sure enough I have my Data Model as input, View Model as output and a LINQ queried data object of Customer passed in to Mapper.Map method. It gives me my View Model as expected.¬†I now use this View Model and pass it down to my strongly typed View.



OK so we have seen what Nuget can do, and how via automapper we can convert the objects quickly into one another without writing any stupid redundant code, without even specifiying the individual member mapping in any of these model, pretty slick I think.

WAIT It is not over yet…

If you are anything like me you would wonder Automapper sure converts the data under the hood nicely but what are the cost that comes with it? Well for this kind of a mapping, not much.. Have a look a this.

Specially the last image.


I am comparing the binding of 1, 10, 100, 1000, 10000, 100000 set of sample models via manual mapping and Automapper, manual mapping ofcoruse is faster but Automapper is not left that far behind. But again this is my i7 with 8 Gb RAM server and you will hardly parse 100000 model on a single shot. Also It’s the application expected use which decide how crucial these timings are and whether it is wise to choose / add conversion layer between your data model and view model. That being said, do not forget this is a smile mapping and not fancy. In part 2 we will have complex model binding and again see if Automapper keeps up the performance like this..

Hope you will stay around…


Times Square on a New Years eve, an amazing experience.

It is always a great experience to do something that has been sitting on your wish list for a while. Being at Times Square, NY was a amazing, tiresome, unique experience, which CAN’T happen anywhere in the whole wide world. I love New York City an…

It is always a great experience to do something that has been sitting on your wish list for a while.

Being at Times Square, NY was a amazing, tiresome, unique experience, which CAN’T happen anywhere in the whole wide world. I love New York City and Times Square. For me It was awesome to be around 1 million people celebrating the new year. Practically the biggest celebration of the new year in the World!!

Yes It was crowded, It was even almost impossible to move your feet without falling or to dance on a song without crushing someones legs but It was all happening, We were a group of 6-8 guys who were waiting on the 46th Street from 2pm for the midnight (Yes we went there around 2 pm and still could only reach around 46th – 47th street), the countdown and the ball drop (42nd street).

Frankly speaking, there is nothing special about the ball drop that 1 million people gather to see. It is just the way it has been, and It’s just the way I think It will be. Its city’s own style of celebrating the new year. The lights of New York City and the music there was the only thing that can make you survive the crowd, the time.

You get the see the live performances by some good singers, for 2012 celebration we had Drake, Justin Bieber, Pitbull and some really cool Spanish singer, I don’t know the name. I don’t care to mention Lady Gaga, as she was boring as hell. If you ever wanna go there, have some quick bites for you handy like chocolates, chips etc. You don’t want to take sodas and drinks with you, unless you wish to rush out to find a place to pee, We had one of that kind in our group, he ended up seeing ball drop from the place where you can not actually see the ball, ūüėõ

The best part for me was that I was with some of my very close friends and we were having a great night, when hungry the pizza guys showed up distributing pizza (NOT FREE…). We caught some flying caps and hit some beach balls around. The crowd near us was friendly and pretty so there was a little to complain except crying feet. The weather was surprisingly awesome which I thought was a great plus point. There is not much you can say, its the energy you feel when you were around the crowd, the music and the event.

And the most awaited midnight came, the countdown was amazing, the shout outs were loud, people were happy, the ball finally dropped, the songs were great, It was as if the most lively city was never alive before. Lovers kissing, Friends hugging, millions of colorful paper flakes fell from the sky.. It was awesome. For me, my girlfriend wasn’t around for the midnight kiss ūüôĀ but I survived that somehow..¬†

Times Square at New Years eve was one of the thing that I wanted to do while I am on the east coast and It finally happened and I loved it.

If you ever want to go, make sure, you are okay with HUGE crowd, have patience, and can stand for more than 6 hours. If so, you should definitely go with your best buds, girlfriend/boyfriend or your spouse if you are still young for this :P.

If you think you would enjoy that, You will have a really tiresome experience but It will all be worth in the end.

Here are some pics if you want to see them..Of course these are just iphone pics in the crowd, If you would like to see really good images search google images for “new years eve 2012 time square”





















Silverlight Event Calendar with MVC 3

I love it when two development technologies shake hands with each other to make a composite product. I have been playing around with integrating one technology with another lately and today’s blog is dedicated to integrate Silverlight control [Cal…

I love it when two development technologies shake hands with each other to make a composite product. I have been playing around with integrating one technology with another lately and today’s blog is dedicated¬†to integrate Silverlight control [Calendar] in MVC 3.¬†For those who are new to .Net development technologies, I suggest you have a look at¬†Silverlight¬†and¬†MVC

It is not always the case when you are bound to use Silverlight in MVC 3¬†solution especially a Calendar control, you can achieve the similar¬†functionality with¬†tools like JQuery, Telerik Calendar Control and many more. However Integrating Silverlight in MVC 3 is not as easy like the above mentioned tools. I ran into¬†this scenario a while back where I¬†was supposed to have an¬†event¬†calendar control in my MVC 2 project and I decided to take a higher route of implementing this by Silverlight just to learn how to integrate it. It was not easy for me to do that the first time but in the end I have to admit it was slick. ūüôā ¬†I will try to give a demo on how to integrate Silverlight Control in MVC 3 razor view. Also you can add other silverlight control just the same way. We will also be using JSON to communicate between Silverlight and MVC 3.

Lets Begin….

 First of all 

1) Add a Silverlight project in to your MVC 3 Project (Select Defaults, let it create a Test page) 

2) In your Silverlight project Add Reference to   System.ServiceModel.Web, System.Runtime.Serialization

After all that your solution should look something like this.. 


Now let’s edit XAML in Silverlight and put a calendar control and textblock in it.



I edited it with some basic design properties and here is how it looks..



Now let‚Äôs create MVC View which will host this Silverlight calendar. To do that Just create a view and locate a file called “YourSilverlightAppNameTestPage.aspx” in my case it is CalendarTestPage.aspx, Right Click ->View Code and copy the script and html ¬†and paste it into your MVC View.

Do not forget to remove Head and Body tags from your MVC View after pasting the content.

Now set the path of your zap file matching inside your ClientBin folder, or simply use the url to that. Here is how it looks in my case.



Notice I have all the height/width value in “px”. Sometimes some browser does not like % with Silverlight and they will not just display the content in that case so try to use px with Silverlight as much as possible.

Put a method to display view in your controller. And run your web project to see if you can see a Silverlight calendar. You should be able to see something like this….




If you cannot see something like this then, check your source path in your view, That is mostly the culprit, Clear your browser cache and try it in different browsers..

Check above steps if you missed any if you still cannot see it.

Ok so now you have a Silverlight calendar in MVC but we didn’t do all this trouble just to display a calendar we want to pass in some data to this calendar and make is a traditional event calendar.. So we add a model in our MVC now.

I just created a CalendarModel like this to show the demo, 



So as I said, you will have a proper db calls to fetch event data or something, in this example a constructor call is enough to have some fake data to test our calendar control… now, In your Controller add a method which fetches this data from the model.. Something like this..



What we did here is we have created a bridge for our Silverlight app to communicate with our mvc and fetch the data for its internal processing..

Now lets code in Silverlight app to get data from this bridge…For this copy the Model you created and paste it into your MainPage.Xaml.cs under your namespace, Why? Because we are going to juse DataContractJsonSerializer which will need the datatype to model to convert json into some sort of datatype.

One can say that why not add a reference to our project and use the model directly, well you cannot add reference of your projects which are not built against Silverlight runtime, so that wont work. 

Anyways.. after you added that into your silverlight, add this code to your file..



Ok so you can see couple of ugly red arrows right, lol, they are ugly to get your attention. So you need System.Runtime.Serialization.Json for DataContractJsonSerializer and this is why we added two references at the begining of our project.

You also need member variable of CalendarModel to store and compare the data on SelectedDateChange event.. We will store the data we get from MVC in this member variable, this is why we need to paste our model in Silverlight project too, so we can create an object of that class which can hold the data that came as Json from our special bridge we made.. 

Notice in Page_Loaded we have created a web client object which will read asynchronously from the “Event” method in our controller [our bridge.. ūüôā ] Also notice that for demo purposes i have hard coded the url [after hard coding the port I am running my web app]

If you deploy it to IIS later on, do not forget to change it to your actual url.

And now finally we have mvc_OpenReadCompleted method, which actually fetches the data from the Json and convert it into our CalendarModel..

Now to make an Event Calendar I have to add these dates to my calendar control hence.. loop going through adding each one in the calendar control…

Now I have not described why i have used member variable loadCompleted in this class, Well here is why, SelectedDateChanged method is called when the calendar control is rendered, which is the same method we are going to use later, to display the details of Meeting.  That variable is a mechanism to differentiate between when this method is called by client (the person using the web page) or by our application while loading the calendar control..

And Finally we just add a SelectedDatesChanged complete the task we started.. 

Here is how it looks.



We are just displaying the details i.e. MeetingTime, MeetingAgenda and Meeting Name here when selected date matches the one that are passed by our MVC. You can do all your complicated stuff here.

That’s it, Finally we will be able to see Silverlight event calendar..

Here is the look



Silverlight is known for its rich media, I will suggest you that if you ever use this, use everything in Silverlight to make is as much pretty as possible so that your efforts look worth, I did it once and I can say no JQuery calendar could look that slick.. 

And we are done…

You now have a decent Silverlight¬†Event Calendar in your MVC 3 project….

I still strongly suggest using JQuery/Telerik Controls for Calendar control, but I understand sometimes things have to be done some specific way and it might be helpful if we have a knowledge of how to integrate different Microsoft technologies together. 

Hope you will stick around… Happy coding..