Steve Smith's Blog

Musings on Software and the Developer Community

Set Up Build Agents By Project in TeamCity

We’re using TeamCity to manage our continous integration builds for CodeProject.com and LakeQuincy.com.  Before TeamCity, I was using CruiseControl.net, and TeamCity is much easier to get working (and requires far less XML manipulation).  I do miss CCTray, which I found to be much nicer than the TeamCity tray notifier (which if you click on it never shows anything immediately – it has to go and get it which imposes a delay – it also doesn’t do sounds like CCTray does – but I digress). Let...

Set Up Build Agents By Project in TeamCity →

Posted on Wednesday, 07 July 2010         No Comments

How Can I Determine The Current Controller or Action in an Html Helper

If you’re writing an HTML Helper for ASP.NET MVC you may want to do something different based on whether the page that is to be rendered was arrived at via a particular controller or controller action.  I found the following code which does just this in one of the ASP.NET MVC Themes available from the www.asp.net web site (the Dark theme, I believe it’s called). Note that I’ve already modified this code to work with the new ASP.NET 4 string encoding and the MvcHtmlString type , as I wrote about...

How Can I Determine The Current Controller or Action in an Html Helper →

Posted on Friday, 02 July 2010         3 Comments

Budding Versus Festering Code

This is in response to Michael Feathers’ recent post on Festering Code Bases and Budding Code Bases . Certainly the default tooling in the Visual Studio space has, until recently, made it dramatically easier to add code to an existing class than to create a new class.  However, tools like ReSharper have a large impact on this, and can make it extremely easy to create new classes, put them in their own files, and move those files where they are supposed to go with just a few keystrokes (and VS2010...

Budding Versus Festering Code →

Posted on Tuesday, 29 June 2010         No Comments

Disable Hibernation on Servers

Here’s a quick tip if you should find several GB of your system drive taken up with hiberfil.sys on a production server machine (as I recently did with a virtual server with a very small C partition) – Disable Hibernation. Disable Hibernation 1. Open a command prompt as administrator 2. Run this command: powercfg –h off 3. Done! The hiberfil.sys file should immediately disappear.  This also works on desktop computers that never use hibernate, of course.  Thanks to SpearMan for the tip. ...

Disable Hibernation on Servers →

Posted on Monday, 28 June 2010         4 Comments

Default Encoding of Strings in ASP.NET MVC 2

If you have ASP.NET MVC 1 code you are moving to ASP.NET MVC 2 (and ASP.NET 4) you are likely to encounter a problem in which your application starts displaying encoded HTML on the page rather than the actual results of that HTML (e.g. you see <a href … /> instead of a hyperlink). One of the greatest features added to ASP.NET 4 is a new way to render content that is encoded by default in your .aspx/.ascx pages/views.  This new syntax uses <%: Model.SomeString %> instead of the ever...

Default Encoding of Strings in ASP.NET MVC 2 →

Posted on Thursday, 24 June 2010         8 Comments

Tagging Releases in Source Control

A best practice when you’re using source control is to tag your releases.  What does this mean, exactly?  If you’re following the relatively standard non-distributed source control repository folder structure of having root folders for: branches tags trunk then it means simply making a copy of the current state of the system when you did your release.  Here’s how to do it using Subversion (SVN) and the TortoiseSVN client, both popular free tools for source control management. Step...

Tagging Releases in Source Control →

Posted on Wednesday, 23 June 2010         2 Comments

Great Uses of Using Statement in C#

In my last post about testing emails in .NET , I noted the use of the using statement to ensure safe usage of the IDisposable SmtpClient and MailMessage objects.  This is the typical usage of the using statement, but you can take advantage of this statement’s behavior for other scenarios as well, resulting in cleaner code. Consider the scenario where you want to perform some kind of pre- and post- processing around an arbitrary block of code.  The simplest scenario I know of is when you...

Great Uses of Using Statement in C# →

Posted on Monday, 21 June 2010         14 Comments

Moving a Certificate Between Web Servers

I’m in the process of moving Lake Quincy Media’s web site from one server to another, and since it uses SSL to secure users’ data, I had to move the certificate to the new server as part of the server move.  Fortunately, this process is quite painless.  First, you need to export the certificate to a .pfx file and give it a password, using these steps: 1. Start, Run, MMC (I did it as administrator) 2. Go to File –> Add/Remove Snap-in 3. Click on Certificates and Add 4. You want Local...

Moving a Certificate Between Web Servers →

Posted on Saturday, 19 June 2010         1 Comment

SQL Server Error User Group or Role Already Exists in the Current Database

If you restore a database and then try to login to it, you’re likely to run into this wonderful SQL Error: User, group, or role ‘whatever’ already exists in the current database (Microsoft SQL Server, Error: 15023). Unfortunately, using Sql Management Studio alone doesn’t seem up to the task of correcting this problem.  You have to drop down to calling esoteric stored procedures (who needs a GUI to actually manage users and logins, right?). Searching for this error at least yields many results...

SQL Server Error User Group or Role Already Exists in the Current Database →

Posted on Saturday, 19 June 2010         No Comments

Testing Email Sending

Recently I learned a couple of interesting things related to sending emails.  One doesn’t relate to .NET at all, so if you’re a developer and you want to easily be able to test whether or not emails are working correctly in your application without actually sending them and/or installing a real SMTP server on your machine, pay attention.  You can grab the smtp4dev application from codeplex , which will listen for SMTP emails and log them for you (and will even pop-up from the system tray...

Testing Email Sending →

Posted on Friday, 18 June 2010         5 Comments