Category Archives: C#

.NET Calling Web Services: Look Out For The “connectionManagement/maxconnections” Setting

If you have an application making web service calls in parallel, you will want to change the maxconnection setting. By default, you will be limited to 2 concurrent connections per endpoint, so even you had 20 threads going, they would … Continue reading

Posted in ASP.Net, C#, Web Services | Leave a comment

Avoid Mixed Content Warnings Using Protocol Relative URLs

“This webpage contains content that will not be delivered using a secure HTTPS connection, which could compromise the security of the entire webpage.” Undoubtedly, you have seen this message while browsing a site over SSL using Internet Explorer. Chrome, Firefox, … Continue reading

Posted in ASP.Net, C#, jQuery | Leave a comment

Using the #warning Preprocessor Directive

Conditional compilation is powerful. One Preprocessor Directive that I like to use to remind myself of a particular condition is #warning. The #warning preprocessor directive will trigger a compilation warning with a specified message when it is hit. For example, … Continue reading

Posted in C#, MSBuild | Leave a comment

C# Suppress Compilation Warnings with #pragma or the SuppressMessage Attribute

Although one would hope that you wouldn’t have to do so very often, sometimes it is useful to explicitly disable code analysis warnings within your application. For example, you could suppress warnings around references to obsolete methods that must be … Continue reading

Posted in Attributes, C#, MSBuild, Visual Studio | Leave a comment

log4net: A Custom Subject SmtpPickupDirAppender With Emails Containing All Referenced Assemblies

The more information you have in your error notification emails the better. Here’s a way you can get all the referenced assemblies into a log4net generated email that has a custom subject line. First, in your application start-up, add the … Continue reading

Posted in C#, log4net | Leave a comment

C#: Regular Expressions to Filter HTML to a Whitelist of Allowable Tags

If you are looking to “sanitize” your HTML to a whitelist of allowable tags, here’s a bit of code that may help. It is a string extension that uses regular expressions to “clean up” your HTML input. The original code … Continue reading

Posted in C#, Extension Methods, Regular Expressions | 2 Comments