Fixing Nuget Issue – Unable to load the service index for source

It turns out when working on a .NET Core project, Nuget has problems restoring/downloading packages. On other projects using an older version of the .net framework, this doesn’t seem to happen. This happens in the office at work because we use a proxy. So to get around the problem, we need to configure Nuget to go through the proxy.

Edit the NuGet.config file located at C:\Users\\AppData\Roaming\NuGet. If you’re browsing to that folder, remember to turn on “Show hidden files, folders, and drives”.

        <add key="http_proxy" value="http://www.proxy.domain:port" />
        <add key="http_proxy.user" value="thedomain\userName" />
        <add key="http_proxy.password" value="base64encodedpassword" />

If your work policy enforces password reset at a regular interval, it’s better to omit the password key from the config and Nuget will still be able to use your default credentials. So you end up with this instead:

        <add key="http_proxy" value="http://www.proxy.domain:port" />
        <add key="http_proxy.user" value="thedomain\userName" />

Now that this is sorted, let me get back to adding more nuget packages to my project.

Setting up reverse proxy using ARR in IIS

When I initially set up Team City at work, I’ve used localhost on Port 85 as the default Port 80 was already assigned to a default Website in IIS. However not many people have access to the server where the site was running and they couldn’t change build configuration and check detailed error logs. So I wanted to use Application Request Routing (ARR) to forward incoming requests from to localhost:85 where Team City was set up to listen to.

I found an MSDN article with very detailed instructions and I followed the steps carefully. It was well explained across 3 webpages (so kudos to the author) and dealt with things like the initial forwarding using inbound/outbound rules, fixing the problem with http compression and dealing with rewriting anchor tags and form action links.

It all worked fine and I was really happy until I saw a message in Team City telling me there was a problem with Web Sockets. After some Googling, it turns out there’s no easy way around it, so I decided to revert the changes I made for ARR in IIS and just updated the Server URL in Team City (Administration -> Server Administration -> Global Settings) and was able to access the UI through

The way ARR works as I understand it is that it forwards requests from a domain to another web app. Since DNS was pointing to a particular server and running on Port 80, which in my case was the default website in IIS 8.5, I believe you could only add the following rewrite rules in Web.config without having to go through all the steps in the link above:

			<rule name="ReverseProxyInboundRule1" stopProcessing="true">
				<match url="(.*)" />
				<action type="Rewrite" url="http://localhost:85/{R:1}" />
					<set name="HTTP_ACCEPT_ENCODING" value="" />
			<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
				<match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:85/(.*)" />
				<action type="Rewrite" value="http{R:1}://{R:2}" />
			<rule name="RestoreAcceptEncoding" preCondition="NeedsRestoringAcceptEncoding">
				<match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" />
				<action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" />
			<rule name="AnchorTagRule" preCondition="ResponseIsHtml1">
				<match pattern="href=(.*?)http://localhost:85/(.*?)\s" />
				<action type="Rewrite" value="href={R:1}{R:2}" />
			<rule name="FormActionRule">
				<match pattern="action=(.*?)http://localhost:85/(.*?)\\" />
				<action type="Rewrite" value="action={R:1}{R:2}\" />
				<preCondition name="ResponseIsHtml1">
					<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/(.+)" />
				<preCondition name="NeedsRestoringAcceptEncoding">
					<add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+" />

The above will forward request from to localhost:85 so change the URLs according to your requirements. It’s as simple as this. The steps in the MSDN article will create those inbound/outbound rules in Web.config but I don’t think you need to go through all those steps, just make sure you’ve got ARR and URL Rewrite installed on your server, that’s it.

I am a pebble!

My life is that of a pebble – The pebble dances to the tune of the waves. It cannot do otherwise. With every movement, it rubs against hard surfaces and loses part of itself. As the river continues to flow, the pebble becomes smooth. Throw it at someone and it will hurt but hold it delicately in your hands and you can feel its gentleness. Nature wants the pebble to stay immersed in the river so it doesn’t harm and looks beautiful from the outside. And that’s where I belong, out of reach.


C# Interview Questions Based on Actual Experiences When I Was Looking for a Job

This is the process I went through whilst looking for a new Senior Developer position in London. I hope this helps other job seekers better prepare themselves.

Company A

1st Stage – Telephone Interview (30 mins)
General chat with the director about what the company does and where it’s headed. Looking to see I thought I would be a good fit.

2nd Stage – Practical Test (3-4hrs)
Create a basic web application using web forms, linq to sql and jquery ui. This assignment was sent by email and could be completed at home, so no time limit really. The project requirements was to create a page with a text field (Name of company) and 3 dropdowns (Speciality, Category and Location). When users type a name in the textbox, jquery autocomplete should be leveraged to suggest names of companies already in the database. Results should be displayed filtered by all 4 fields if specified. A sample data in spreadsheet format was sent but it was not normalised and a either a backup of the database or script to recreate it was asked.

Here the employer is looking for good coding skills and a layered project solution (Web, Data and Business layers).

Third Stage – Face to Face Interview (1hr30)
This was done at their office in Chiswick. I met the IT Director who asked a couple of questions about the things I’ve put on my CV and what I thought about the project I had to do, then was questioned by a Senior Dev about these:

1. Whether I’ve created a jQuery plugin before (and how)
2. My experience with Unit Testing
3. A couple of other technical questions which didn’t require much thought

Then I met the CTO again for a brief talk and the most important question there was what I would bring to the company.

I didn’t get the job. They said I had strong technical skills but didn’t show much interest in the company.

Company B

1st Stage – Technical Test (1hr23)
I was asked to do an IKM (International Knowledge Measurement) .NET WEB DEV test. To be considered for the role, you need to get 90% and above. IKM tests are multiple choice questions with 1 or more correct answers. You cannot skip a question and come back to it and for each wrong answer, you are penalised more than if you don’t answer it (this is to prevent guesses I think). There were 33 questions to be answered in 83 minutes and before the test, it mentioned that on average people take 39 minutes to complete this.

Some of the questions which were asked are:

1. Which attribute flag to use for bitwise operator (i didn’t know, never used it in my life!)
2. try catch block code segments, which were correct
3. MVC routing
4. Code segments containing interfaces and classes, find out the output
5. Custom exceptions in .net

Although I scored 86%, the company still wanted to see me.

2nd Stage – Technical Interview with Technical Architect and Product Manager (1hr30)
I was asked 2 main technical questions – my understanding of SOLID principles and how I would go about designing a system. The requirements were that a short blog post (140 characters) will be submitted by multiple registered users of the company and this had to be displayed back to on the front end bearing in mind this is a high traffic website.

What was important here is to mention that the first time the page is requested, it will be cached until another post is submitted by someone else. Then on the front end, to use something like SignalR or another polling method to update the post widget with the latest items.

I didn’t get this one either because they didn’t think I would be a good fit for their company and I didn’t know much about their products and services. They said I had strong technical skills though.

Company C

1st Stage – Telephone Interview (30 mins)
Basic introduction to the company and lots of technical questions as follows:

1. Choose two programming languages and talk about the differences – they wanted a client side scripting language like JavaScript and server side language like C#
2. What does .net code get compile to and what is used at runtime (code gets compiled to MSIL and at runtime it’s machine language)
3. What is a transaction in database terms? (going from one consistent state to another)
4. Properties of database transactions (ACID properties)

2nd Stage – Face to Face Technical Interview (1hr)
This was meant to be 1hr but lasted for 3hrs!!! There was a 15 mins presentation of the company, what it does etc. Then oral questions:

1. Explain the Garbage Collector (you should talk about Generation 0/1/2 and that it is non-deterministic)
2. What is IDisposable and what pattern uses this (when using the “using” keyword)
3. What is multi-threading
4. How to avoid a deadlock
5. Difference between the out and ref parameters when passing a value/reference type

Then technical exercises:

1. A program was written on paper that does string manipulation (tokenisation) and you had to tell the output. It was using indexOf and SubString but since there was a do-while loop, you had to calculate values of all local variables on paper. It turned out the interviewer had an initial string of “This is Value1” and you were looking for the word “is” and you would miss out that the first occurrence of “is” would be in “This”.
2. Following on the previous exercise, I was asked how I was going to rewrite the program by using recursive calls to the method and I was only allowed to modify certain sections of the code, not everything.
3. On paper, a set of tables was shown and I was asked how to make it better (had to normalise them)
4. A database schema was shown and i was asked to write SQL queries for inner joins, left joins, group by on paper.
5. There was also a Psychometric test (aptitude) where I was given increasing levels of difficulty to solving a certain mechanism they use for their product.

This was followed by a chat with one of the managers, whereby he wanted me to talk more about the technical stuff I’ve done in my previous jobs (technology used, why and how) and then questions about why I wanted to join their company.

This was one of the hardest interviews I’ve had and I thought it was going to be just 1hr, not 3hrs!!! It was absolute torture and I wanted to just leave in the middle of the interview but I gave it my best shot anyway. I know I didn’t do well but if the interview was that hard, I don’t think I want to work there and have my stress levels jump through the roof everyday. I also have a life outside work and I’d rather take a pay cut than become a zombie. I was later informed I didn’t get the job.

Good luck if you’re seeking a new opportunity!


I had two other interviews after those and got job offers for both. I took up one of them and I’m very happy with the salary and the job I’m doing ūüôā

That’s it – I’ve gone vegetarian now!

I woke up yesterday (26 December 2014) and I felt it was high time I stopped eating meat. I’ve wanted to do this since a long time but there were 2 reasons which¬†prevented me from doing it.

First, it was more convenient – if I’m hungry, I can just make a chicken burger and have that with bread and I’m all sorted. If I’m out and about, I can always get a Zinger burger at KFC. If I wanted to cook a nice meal, you can’t go wrong with chicken which is what I’m used to anyway.

Secondly, I want to put on some more muscle mass and meat is an easy source of protein which is crucial in bodybuilding. I was scared I wouldn’t be able to bulk up if I stop eating meat but the truth is I wasn’t gaining lean muscle mass anyway because I don’t train as hard as I need to (I hardly exercise btw :D).

I guess when I woke up, I thought enough was enough and I could go on procrastinating about this and never get it done. It is boxing day and the Christmas and 2015 New Year celebrations are still intense and in my mind, I’m thinking maybe I should wait till January and have this as a New Year Resolution instead. However I know deep down it’s an excuse and if I put it off for another day, then I’ll never be able to do it.

I just bought 36 chicken burgers, chicken sausages and still have some chicken breasts in the fridge and tuna cans in the cupboard and I’m thinking I should probably get through these first otherwise it’s going to waste. But then I know myself too well now and decided to just go with the flow, so let’s see what happens next.

Using Jabbr chat with MySql database

I wanted to integrate a .net chat application for my Mauritius Chat project and came across Jabbr which has most if not all of the features I wanted. However it works with SQL Server Express by default but I wanted to use MySql instead. The reason for that is that I’ve got a dedicated where I’m running MySql because it’s free compared to SQL Server 2008/2012 and I didn’t want another service for SQL Server Express to run just for one application – I have to use the limited RAM carefully. So this post is all about how I finally managed to do that.

First thing first – you have to download the source code from Jabbr repository on Github, There’s a Download Zip button on the left hand side.

Next you’ll need to download the MySql .Net Connector 6.9.3¬†and install it. If you have previous versions of the MySql .Net connector, like I did, you’ll have to uninstall that first.

These are the changes you’ll need in your web.config file:

Connection String

<add name="Jabbr" providerName="MySql.Data.MySqlClient" connectionString="Database=Jabbr;Port=3203;Data Source=localhost;User Id=YourUserName;Password=YourPassword;"/>

Entity Framework

<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />

You will also need to reference the MySql.Data.Entity.EF6.dll in your project. You will find that where the MySql .Net Connector has been installed and you will have to choose the assembly according to the .net version you’re using, in my case .net 4.5.

Problems I encountered

When you recompile the project, you’d think it will work but for me it didn’t because it kept complaining about this error:

Schema specified is not valid. Errors:
(15,12) : error 2019: Member Mapping specified is not valid. The type ‘Edm.DateTimeOffset[Nullable=False,DefaultValue=,Precision=]’ of member ‘When’ in type ‘JabbR.Models.Attachment’ is not compatible with ‘MySql.timestamp[Nullable=False,DefaultValue=,Precision=0]’ of member ‘When’ in type ‘CodeFirstDatabaseSchema.Attachment’.
(40,12) : error 2019: Member Mapping specified is not valid. The type ‘Edm.DateTimeOffset[Nullable=True,DefaultValue=,Precision=]’ of member ‘RequestPasswordResetValidThrough’ in type ‘JabbR.Models.ChatUser’ is not compatible with ‘MySql.timestamp[Nullable=True,DefaultValue=,Precision=0]’ of member ‘RequestPasswordResetValidThrough’ in type ‘CodeFirstDatabaseSchema.ChatUser’.
(66,12) : error 2019: Member Mapping specified is not valid. The type ‘Edm.DateTimeOffset[Nullable=False,DefaultValue=,Precision=]’ of member ‘When’ in type ‘JabbR.Models.ChatMessage’ is not compatible with ‘MySql.timestamp[Nullable=False,DefaultValue=,Precision=0]’ of member ‘When’ in type ‘CodeFirstDatabaseSchema.ChatMessage’.
(95,12) : error 2019: Member Mapping specified is not valid. The type ‘Edm.DateTimeOffset[Nullable=False,DefaultValue=,Precision=]’ of member ‘LastActivity’ in type ‘JabbR.Models.ChatClient’ is not compatible with ‘MySql.timestamp[Nullable=False,DefaultValue=,Precision=0]’ of member ‘LastActivity’ in type ‘CodeFirstDatabaseSchema.ChatClient’.
(96,12) : error 2019: Member Mapping specified is not valid. The type ‘Edm.DateTimeOffset[Nullable=False,DefaultValue=,Precision=]’ of member ‘LastClientActivity’ in type ‘JabbR.Models.ChatClient’ is not compatible with ‘MySql.timestamp[Nullable=False,DefaultValue=,Precision=0]’ of member ‘LastClientActivity’ in type ‘CodeFirstDatabaseSchema.ChatClient’.

Basically in the Jabbr code, some of the properties (especially for DateTime) are marked as DateTimeOffset which is stores the date/time as an offset of UTC, rather than the server date/time. However the DateTimeOffset type was being mapped to datetime in MySql and Entity Framework realised it was not a proper mapping. I tried to check for solutions online but couldn’t find any and since this was not a big deal for me (storing the date/time as UTC), I ended up replacing the properties marked as DateTimeOffset as DateTime. When you do this, you also have to modify some parts of the code where it uses DateTimeOffset.UtcNow with just DateTime.Now. I’ve used replace/find and there are less than 5 occurrences if I remember correctly.

Okay at this point, the application compiles¬†but when browsing the site, the application tells me that there’s not database/matching tables yet so I would need to use the Package Manager Console and run the command Update-Database. When I did that, it failed at one specific migration. So I tried to see what was happening by issuing a Update-Database -verbose command and I noticed MySql was complaining about a variable was not declared. That specific migration to was to rename a column from Proivder to Provider, something like that. So I thought I could just exclude that particular migration and do the rename manually but the migration still failed at another point.

I therefore decided to delete the whole Migrations folder so that the schema is created from what’s in the code without having to run it any migrations (this is only good if you’re just setting up the website and you don’t have any data yet). I had to comment out the Migration calls in Startup.cs and run the following command in Package Manager Console: Update-Database

I also issued Enable-Migrations so that if I make any changes, then these are tracked.

In the end, I was able to run Jabbr chat with a MySql database. Now I need to create a custom membership provider so that logins details are checked against the Users table which resides in another project, so I might need to create an API for that.

Setting Git on external hard drive or USB flash in Windows

At home, I usually work on personal projects and I wanted an easy way to back up my data and put my code under source control. I decided to go with Git for this and use my 250Gb external hard drive for the remote repository (you can use a USB flash drive as well if you want).

So the first thing to do is download Git Extensions and install the software. I installed mine on the C drive in Windows 7 using the default settings.

The next thing was to let Git know where my local repo for my project is. So I browsed to the folder where my project was located (the directory which contains all the C# source files from Visual Studio) and right click. This gives you the option for “Git Init here” which when chosen creates .git directory marking this folder as your local working directory. Open your Git Extensions program and do a commit to get your codes under source control (locally).

Once that is done, you’ll need to create a remote repository on your external hard drive or USB stick. Just create a folder there eg H:\Git\MyProject and when you right click in the folder, you will be able to click on the “Git Bash” option which will open a command line tool. Type the following command in there:

git init –bare

This will create a bare repository in the current directory.

Go back to¬†Git Extensions and do a push now. It will ask you where to push to and you just need to enter the location of the¬†remote repo you’ve just created and voila, all done.


Although I was able to set up the local repo using Git Extensions, I was not able to do the same for the remote repo, hence I’ve used the command line in Git Bash.

The local repo contains all your source code (it’s a working copy after all) but the remote one has only git files. My local repo was 8Mb while the remote one was only 0.5Mb so I was worried it was not a proper backup of my data. However that was not the case – I tried to get another working copy from the remote repo just to make sure that if my computer crashed, I would still be able to get all my source codes from the external drive and that worked perfectly. Actually it’s better because the size of the remote repo backup was way less than the working copy.

Tere Dard Se Dil Aabaad Raha English Translation

This is a lovely song from the movie Deewana starring Divya Bharti, Shah Rukh Khan and Rishi Kapoor.


Tere dard se dil aabaad raha
From your pain, my heart was prosperous/affluent
Kuch bhool gaye, Kuch yaad raha
I forgot some, remembered some
Naseeba bhi kya rang laya
Faith/luck too, has brought its different colours
Kaha laake hum ko milaya
Where has it brought us to meet
Apni wafaa ke gul khil na paaye
The flowers of our trust did not flourish
Milke bhi tujhse hum mil na paye
Even after meeting you, we didn’t really meet
Darde dil hum kaise sahen
How can I stand this heartache
Door bhi hum kaise rahen
How can I stay far away too
Tera gham tere jaane ke baad raha
Your sorrow was there after you left
Kuch bhool gaye, kuch yaad raha
I forgot some, remembered some
Jaane wafa tujhko kya de
My life, my faith, what can I give you
Dil Keh raha hai dua de
Heart tells me to give blessings
Armaan bujhe hain sapne duaan sa
Desires are extinguished, dreams are broken
Mar mar ke hum to zinda yaha hai
I am still here alive after dying over and over
Bekhudi main hum ko gaye
I had lost all conscious/senses
Phir juda tujhse ho gaye
Then I was separated from you
Chahat ka jahaan barbaad raha
The universe of love was destroyed
Kuch bhool gaye, kuch yaad raha
I forgot some, remembered some

Conversation of my Mind to my Heart

Mind : I know you’re hurting badly but that’s affecting me a lot now and I cannot function properly

Heart : I’m sorry but I can’t help myself

Mind : For our sake, forget her and move on

Heart : I’ve tried to but it’s out of my control

Mind : Just do what it takes to stop this madness

Heart : Alright, I’ll have to stop beating then

Mind : No, you know I cannot exist without you

Heart : …and I cannot live without her

Mind : We’re both screwed then!
Soul : Don’t worry guys, when the two of you are long gone, I’ll use the memories of the Mind to cherish the love of the Heart and immortalise your existence¬†

EPiServer Dynamic Content not Rendering on page

After spending like 4hrs trying to find out why a dynamic property was not being loaded properly on a webpage, I finally stumbled upon a website with such an easy solution. Basically we had a custom dynamic property which was supposed to output some data but EPiServer was not rendering the control properly.

In the source code, I expected to find :

<a style=”” href=”/Video/Vimeo/60255727/” class=”trigger-video” data-trackingid=”&lt;a href=”><span></span>
<img src=”/Global/PersonalCover-Screengrab.jpg” alt=”Personal cover” />

…but here’s what I saw instead:

<div data-classid=”b30218a7-77fc-43dd-a844-81935aa9b35e” data-dynamicclass=”Video Plugin” data-state=”VgBpAGQAZQBvAEkAZAA=&amp;NgAwADIANQA1ADcAMgA3AA==|VAByAGEAYwBrAGkAbgBnAEkAZAA=&amp;PABhACAAaAByAGUAZgA9ACIAIgAgAG8AbgBjAGwAaQBjAGsAPQAiAF8AZwBhAHEALgBwAHUAcwBoACgAWwAnAF8AdAByAGEAYwBrAEUAdgBlAG4AdAAnACwAIAAnAFYAaQBkAGUAbwAnACwAIAAnAFAAbABhAHkAJwAsACAAJwBQAGUAcgBzAG8AbgBhAGwAQwBvAHYAZQByACcAXQApADsAIgA+AFYAaQBkAGUAbwAgAGwAaQBuAGsAIABoAGUAcgBlADwALwBhAD4A|SQBtAGEAZwBlAFUAcgBsAA==&amp;LwBHAGwAbwBiAGEAbAAvAFAAZQByAHMAbwBuAGEAbABDAG8AdgBlAHIALQBTAGMAcgBlAGUAbgBnAHIAYQBiAC4AagBwAGcA|SQBtAGEAZwBlAEEAbAB0AA==&amp;UABlAHIAcwBvAG4AYQBsACAAYwBvAHYAZQByAA==|QQBsAGkAZwBuAFIAaQBnAGgAdAA=&amp;” data-hash=”jpJE7dVU4KCYCarsF+2bNaNENaNdJwG1niTwbyZc7CY=” contentEditable=”false” class=”epi_dc”><div class=”epi_dc_h”><div class=”epi_dc_l”><div class=”epi_dc_title”>Video Plugin</div></div><div class=”epi_dc_t”><a href=”#” class=”epi_dc_editBtn”>.</a><a href=”#” class=”epi_dc_previewBtn”>.</a></div></div></div>

EPiServer was not rendering the control properly but was just outputting the string.

The fix is really easy. All I had to do was change the way the dynamic content is being output in code.

So instead of this:

<%= CurrentPage.MyDynamicContent %> // wrong

I used this:

<EPiServer:Property runat=”server” PropertyName=”MyDynamicContent” />

Note that this is the way to render dynamic content in EPiServer but there’s a way you can force the literal output as well to work.