Interesting notes on Docker Windows containers

In this post, I collected some useful links and notes when trying out Docker on Windows with Windows containers.

Useful images

Useful commands

Some notes

  • You do not see the Mount/Disk setting in Docker when using Windows container instead of Linux container because this is not necessary according to the documentation. However, you have to pass in correct parameter for the volume; for instance, C:\data_in_host:C:\data_in_container  or C:/data_in_host:C:/data_in_container  instead of C:/data_in_host:/data_in_container . Check the following links for more information: https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-storage.
  • You cannot test with http://localhost:{host_port} on Windows. You will have to use either http://{host_name}:{host_port} or http://{container_ip}:{container_port}. To find out container IP, you can use docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' container_name.

Links & Examples

https://docs.microsoft.com/en-us/virtualization/windowscontainers

https://anthonychu.ca/post/dockerizing-aspnet-4x-windows-containers

Deploying ASP.NET Core applications to Docker containers

Migrating Legacy UUID of MongoDB to standard UUID

MongoDB has a legacy format for UUID which causes problem where the UUID is interpreted differently on different platforms, and the standard UUID solves that exact problem.
However, the C# driver defaults to use legacy format and requires switching to standard format explicitly.

Moreover, after switching to standard format, you might get Exception due to existing UUID. You can fix that Exception by using the Python script below to migrate legacy UUID to standard UUID while maintaining the same C# GUID translation:

After running the script, you can then replace ‘my_collection’ by ‘my_collection_new’.
Based on your actual need, you may also replace CSHARP_LEGACY with JAVA_LEGACY or PYTHON_LEGACY or other legacy format (http://api.mongodb.org/python/current/api/bson/binary.html).

Hope this help!

“Access is denied” when using Microsoft Speech Platform with IIS

When you are using Microsoft Speech Platform in your web service to perform speech recognition, you might find a strange situation when the web app works perfectly in Visual Studio, but keep having “Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))” when you try to instantiate SpeechRecognitionEngine.

After some searches on the Internet, I found 2 suggestions in this article http://stackoverflow.com/questions/3385382/run-microsoft-speech-over-iis:

  • Use procmon in SysInternals to find ACCESS DENIED result and add permission there
  • Grant read permission for the IIS apppool account to folder

I tried the second suggestion first as it is more straight forward, but it didn’t work out for me. I then tried the first suggestion.

Turned out the path is a bit different on my PC, probably due to x64-x86 compatibility.
Access Denied problem

I added read permission for

to the folder above (and some of its parents), and the speech platform works perfectly in IIS now.

I hope this article would help you if you have to same issue. Please also leave a comment if you have a better solution.

How to prepare a HTML email for your web application

As many of my other posts in this blog, this will be a note-to-self, collecting all the tidbits that I have learned in preparing a HTML email that would show properly (or as expected) in major email clients during the development of my latest application.

Below is a short list of my suggestions.

  • Use <table> and nested <table> instead of <div> for your layout
  • Don’t create table cells with the height of 1px
  • Don’t use <tr> to create top/bottom padding
  • Don’t use <p>
  • Use a <tr> for each paragraph
  • Don’t rely on page level CSS
  • Don’t try to put fancy styles in <a>
  • Be careful when putting URLs in the email content
  • Test as much as possible


There any many excellent articles on the same topic. I will try to collect them here in the future when I have more free time. In the mean time, if you know any good article, or have better solutions than what I have suggested, please feel free to comment below.
Read More

Posting raw JSON string with jQuery

If you are using jQuery’s ajax function to post raw JSON string to your APIs, you might get some problem when your API does not receive the correct content, or in the case of ASP.NET Web API and parameter binding, you may get null input parameters in your controller.

The JavaScript can be as simple as this.

And the post action of the Test API controller be something like below.

The post action will not get “inputparameter” as the value of variable input; instead we get a null value.
Read More