Friday, February 26, 2016

WCF Timeouts

Timeouts can be configured on either the client side or the server side.  They are set on the binding element in the web.config file.  See here for the specific details.

Client side timeouts are pretty self explanatory.  If you don't receive the response in the specified time period, the connection is closed and your code moves on.  Server side timeouts work a bit differently than I expected.  First of all, when you set a server side timeout, you are saying "After the connection is opened up, if I don't receive the full request in the specified amount of time, I'm going to time out."  What it is not saying is "If I receive the request and it takes me longer than the specified time to process the request, I time out."  You'll just keep churning away probably until your database connection times out.  I believe client side timeouts are set to a minute by default, but can be lengthened.

Thursday, February 25, 2016

Hosts file location

C:\Windows\System32\drivers\etc

This is where it is located in Windows 7.

Monday, February 1, 2016

Favorite Visual Studio Options

I recently upgraded to Visual Studio 2015, and had to set it up to my liking.  Since I only upgrade about every 2 years or so, I always forget where these settings are.  So, today, I'm going to make a note of these settings:






Monday, December 14, 2015

Thursday, November 5, 2015

Prevent "Click Jacking"

One way to prevent "Click Jacking" is to prevent other sites from displaying your site in a frame.  To accomplish this, simply add this to your web.config:

<system.webServer>
 
...
 
    <httpProtocol>
        <customHeaders>
            <add name="X-Frame-Options" value="DENY" />
        </customHeaders>
    </httpProtocol>
 
...
 
</system.webServer>


Friday, October 30, 2015

.NET Exceptions

This post may seem obvious, but is something that I never knew for sure until today.  When an exception is raised, a stack trace is included as a property of the exception that describes where the exception occurred.  The stack trace will always reveal the method where the exception originated.  Even if Function A calls Function B, and Function B raises an exception that is caught in Function A, Function B will be in the stack trace.  This small bit of knowledge can save a bunch of time, because if Function A is in the stack trace, you can rest assured that it didn't happen in Function B.

Wednesday, October 21, 2015

Git Line Endings

When editing a text file in Windows, the operating system inserts two characters: carriage return and a line feed (AKA CRLF).  In any other operating system, only the LF character is added.  Because some projects are developed collaboratively on different operating systems. Obviously, this poses problems.  Git offers different configurations to deal with this.  With one configuration, Git will automatically replace CRLF with LF upon a commit.  I was stuck with this configuration one day because I believe I mistakenly told it to set it up that way during installation.  You don't want this if you do all your developing in Windows.  To turn this off, use this command:

git config --global core.autocrlf false