Nothing That Is Right

Nothing that is right makes sense at first.  It is as we press through the darkness that we then discover the warm glowing feeling. Even then it is just a piece of the puzzle. On to the next thing through which we again pierce through the darkness to hit or miss the validation of the warmth from that glow we seek. 

Hubris

Yesterday I was fixing a defect with an ETL util I wrote. When I found it I smiled and I couldn’t believe I had made the error. Today someone reported a defect with a different ETL util I wrote that’s scraping data from a completely different source. Different error all together, different source, different target data store… the best part of yesterday’s bug and me finding it myself was that it prepared my mind for today’s bug. Cause the first thought yesterday was: Really I made that mistake? :-) 

C# HttpWebRequest getting the actual HTTP Code

I’m testing web services that are going out to production tonight.  

These services are REST services.  

In my testing I was trying to get the actually HTTP Code from the response object that gets bounced back to me. 

My expectation was that I could do that by just accessing the StatusCode property on that object.  

That is not really how it works.  

StatusCode gives you what in most other frameworks would be viewed as a status message. 

Once again a combination of Google and Stack Overflow to the rescue!

I discovered that I can get the code by casting the property value returned to an int. 

Which allows me to do my comparisons and log the result data and this is truly delightful!

Here is the before example:

HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();

Here is the after example:

Console.Write((int)response.StatusCode);

Click here to get the full stackoverflow.com HttpWebRequest post.