Things I need to remember... IIS Express ports for HTTPS and Configure WCF Rest endpoints for HTTPS

Don't Forget
As I have been writing consistently for a bit now I've already found myself referring back to things I've posted, which has prompted me to try and post items which have taken a bit of time to work out. It seems that the act of "writing it down" causes me to remember information better. Perhaps it's all the thought into attempting to write something useful.

This post includes two details which took me more than a few hours to sort out so I hope to help others who have a similar need. Funny enough it could be me in the future after I've forgotten this information.

First up is a little detail that I know I've forgotten and looked up more than once, and depending on the google/bing results I find sooner or later.

Setting up IIS Express to host a site via HTTPS

When configuring your site to run in IIS Express using Visual Studio it's fairly trivial to set the attribute to use SSL (i.e. HTTP over SSL which is HTTPS) as it's just an "enable" in the drop box for use SSL. Additionally when you do this it will ensure that a local cert is setup as well which should be locally trusted so that the browser doesn't through any warnings; but a detail that could trip you up is you'll need to use a PORT within a specific pre-allocated range as IIS Express grabs the range just for this purposes.

Port range 44300 to 44399

A great troubleshooting at pluralsight that includes this little gem on port ranges along with other tips.

Setup bindings for WCF REST service end-points to use HTTPS be default

I'll be the first to acknowledge that this is really legacy information as WCF REST services have been essentially deprecated by .NET WebAPI technologies, and for that I'm VERY pleased; however, working with legacy technologies has NOT been deprecated so I'll post this here for others benefit.

This nugget of information took me the better part of the morning to dig out of a the Microsoft site on A Developer's Introduction to Windows Communication Foundation 4.

The detail I needed was found under the sub-heading aptly named Default Binding Configurations where it outlines that if you would like a particular binding to be used by default you simply need to create the binding without a name and by this convention all service end-points will, be default utilize this binding. The same is true of a behavior configuration, omit the name property and the binding or behavior is adopted by all services defined in the project.

From the same document they provide the following sample which I've replicated and modified to demonstrate how to enable HTTPS for all your service end-points.


<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding>
<security mode="Transport" />
</binding> </basicHttpBinding> </bindings>
</system.serviceModel>
</configuration>

.NET MSTest and DeploymentItem Attribute

I was recently reminded that order of operation can byte you when trying to troubleshoot intermittent unit test failures.

First, I’ll be the first to admit that if you want to avoid problems with unit testing it’s best to avoid any dependency outside of your actual code base, things like databases, API and even the file system are best avoided in execution of your unit tests. That last one, the file system, in some applications is really hard to avoid.

If you happen to be using MSTest, a helpful attribute for your test is DeploymentItem. This particular attribute allows you to define a file within your unit test project assuming it’s marked as “Copy Always”. With this attribute in place you can then combine this with TestContext.DeploymentDirectory to find this sample file and then do what you need to do.

In my particular case I was having an issue with the unit tests failing on the build machine but not locally. After stumbling around for a bit I finally feel back to the old debugging standard of printing out the entire directory of files to the console. It was at this point that I realized I was able to create files in the expected location so why could I not find the DeploymentItem? The answer, side effects.

In one test I “moved” the resource item, and it had just been a situation where locally the tests “happen” to execute in an order such that the move operation was happening at the end of the test cycle, thus masking the problem. When I switch the test in question to “copy” the file, which was still a valid test mind you my problems went away.

As an alternative approach to solving this problem you could make the file an embedded resource and then, in the arrange part of the test, write out the file to disk and then perform the test to ensure that the file always exists at the start.

I hope this information helps others avoid wasting time with these type of silly order of operation problems.

Keep Calm and Get the Facts

KEEP CALM and GET THE FACTS It often amazes me at how often I find myself apologizing to others for rashly commenting on a problem before I have all the facts. In fact, after so many years as a professional in the IT space and dealing with countless critical situation/severity one problems (a.k.a. Sev1, crit-sit) I would be able to react in a more appropriate and beneficial manner. The sad truth is that, as I write this post. I JUST "did it wrong" on a Sev1 from earlier in the day and found myself sheepishly apologizing for my brash response.

Perhaps by writing this down and publishing for others to read I can obtain the positive results of public shame to result in my correcting my behavior. At least there is a chance someone else can read this and benefit from my mistakes.

The fundamental problem I seem to have is that I hear a few pieces of information or even just the subject line of an e-mail or short text message and immediately jump to a conclusion. Having done a bit of a personal post-mortem, I find that this tends to be my go to response when there is a heightened sense of urgency. Perhaps when there is a Sev1 and my flight or fight response kicks in the adrenaline kicks in and causes my brain to overly react, at least that is the excuse I'm going to tell myself. What can I do about this? First, remember to breath, while it is perhaps a cliche it has been proven over and over again that taking a few deep breaths and making sure you have oxygen flowing helps you to think clearly. I also, personally, think that the time it takes you to breath can help dissipate some of that "nervous" energy that is initially kicked off by the excitement.

Even if you forget to take the deep breaths, the one detail that must not be forgotten is this... Get the Facts. This is summed up quite nicely in a wise proverb which reads "When anyone replies to a matter before he hears the facts, it is foolish and humiliating" (Proverbs 18:13). Let me tell you, I feel like a fool when I realize that I've spoken about a problem, incorrectly. and it all could have been avoided simply by obtaining all the facts, which often are readily available.

Related to this, when you find that facts you have distributed were inaccurate, it is vital to attempt to distribute the correction as quickly as possible. Even if you find that you don't have corrected information, but you know what was previously stated was inaccurate, it's helpful for others to know that so that decisions are not made on faulty details.

I hope that my faults and lessons learned will be of benefit to others going forward.

Compose a message through some else’s eyes

Twilight Zone: The Eye of the Beholder
I've always enjoyed science fiction work that intended to make the onlooker reflect on their world view, you know, really make you think about yourself. A wonderful example of that is the classic Twilight Zone: The Eye of the Beholder.

Although I don't think it's needed at this point I will mention there are spoilers about this particular episode.

The story outlines the tragic plight of a woman who has been horrible disfigured and all other attempts to make her look "normal" have failed until this final last ditch attempt. Through out you don't see the woman or the faces of the other characters. That is until the end when they unveil the woman by removing the bandages and you see, what at the time of filming, would have been considered an attractive movie star and as the camera pans around you also realize that everyone else appears to be "disfigured" according to what the vast majority of humans look like. Now your mind is blown and you spend the rest of the day really thinking about what you consider "normal". Mission accomplished.

Clearly this is a story that attempts to drive home the point that, as the old adage goes "beauty is in the eye of the beholder". Well the principle can hold true for our communication. The meaning of our words, written, spoken, etc. are in the minds of the recipient.

While I agree that what constitutes a normal appearance is very subjective and is driven by cultural biases and trends of the time I would propose that communication can fall into this same arena, but in a sort of microcosm of time. Most of us have probably experienced a situation where you've sent a text, e-mail or social media post and the results where widely varied. After getting this feedback and re-reading the message through the lens of those other readers you can clearly see why they interpreted your words as they did.

This does not always mean that something horrible was conveyed or that you horrible offended a portion of the population, it could simply be that there was a misalignment, but still wouldn't it be great to find ways to avoid it in the first place. Perhaps these next communication tips could help you as they have helped me.

Know your audience and write to them, not to yourself. When you draft communication or are speaking to a group consider the audience and avoid the trap of assuming they know what you know. This doesn't mean you have to spell out every little detail and link to a thousand different references, but be aware that terms often have context and you should try to explain the context when possible as this can avoid a great deal of misalignment.

Tone of voice DOES NOT travel across written word without a HINT. This is easily illustrated in the form of j/k. When you write a text message to someone that is clearly meant to be sarcastic tacking a little j/k at the end avoids the possibility of the other person taking your words literally. It is wise to do this in all formal settings, such as speaking to a larger group beyond your immediate colleges or friends that probably better understand your sense of humor.

When you have the benefit of having some time to draft a response consider re-reading a message after some time passes from initially writing it. Not only will you catch obvious typos you may find that portions of the message carry a tone you didn't intend. Maybe you were hungry when you were writing and rushed through something or you had a bad morning due to something completely unrelated. Take a break and return to re-read with a "fresh" pair of eyes.

I hope this will benefit you as much as it has benefited me. As I've found effective communication and the conveying of ideas in a way that aligns two unique personalities is like having a super power and I'm sure if harnessed correctly it can be used to conquer the world.