<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Storm Blog &#187; Web Development</title>
	<atom:link href="http://www.storm-consultancy.com/tag/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.storm-consultancy.com</link>
	<description>Web Design News &#38; Tutorials</description>
	<lastBuildDate>Thu, 09 Feb 2012 09:25:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Where to find Rails&#8217; default validation error messages</title>
		<link>http://www.storm-consultancy.com/development/random-bits/where-to-find-rails-default-validation-error-messages/</link>
		<comments>http://www.storm-consultancy.com/development/random-bits/where-to-find-rails-default-validation-error-messages/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 09:25:38 +0000</pubDate>
		<dc:creator>Adam Pope</dc:creator>
				<category><![CDATA[Random Bits]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.storm-consultancy.com/?p=1227</guid>
		<description><![CDATA[I&#8217;ve been playing around with simple_form and I18n in Rails a LOT in a recent project.  I&#8217;ve been customising form labels and validation messages using the internationalisation features &#8211; it works really, really well.  There is, however, one small problem.  When you start, you are presented with an almost blank YAML file and some very [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with <a href="https://github.com/plataformatec/simple_form">simple_form</a> and <a href="http://guides.rubyonrails.org/i18n.html">I18n</a> in Rails a LOT in a recent project.  I&#8217;ve been customising form labels and validation messages using the internationalisation features &#8211; it works really, really well.  There is, however, one small problem.  When you start, you are presented with an almost blank YAML file and some very flakey documentation at the bottom of the simple_form readme.  How do you know how to structure that YAML file?  What attribute names should you use?</p>
<p>One of the best resources I&#8217;ve found so far are the defaults files in the Rails source code.</p>
<p><a href="https://github.com/rails/rails/blob/master/activemodel/lib/active_model/locale/en.yml">https://github.com/rails/rails/blob/master/activemodel/lib/active_model/locale/en.yml<br />
</a><a href="https://github.com/rails/rails/blob/master/activerecord/lib/active_record/locale/en.yml">https://github.com/rails/rails/blob/master/activerecord/lib/active_record/locale/en.yml</a></p>
<p>That gives you a full list of the attribute names to use for different validators.  For example, if you&#8217;re using a <em>validates_format_of</em> validator, you can quickly see that you need to use the <em>invalid</em> YAML attribute.  Good luck guessing that one!</p>
<p>The looking at the source trick can also be very useful for gems.  I&#8217;ve spent ages Googling for the correct YAML attribute to use for the validates_email_format_of gem with absolutely no luck whatsoever.  30 seconds on Github and I find the <a href="https://github.com/alexdunae/validates_email_format_of/blob/master/lib/validates_email_format_of.rb">source file</a> which tells me the attribute for an invalid email address is <em>invalid_email_address</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.storm-consultancy.com/development/random-bits/where-to-find-rails-default-validation-error-messages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Nicely format compressed and minified JavaScript in Chrome</title>
		<link>http://www.storm-consultancy.com/development/tips-tricks/how-to-nicely-format-compressed-and-minified-javascript-in-chrome/</link>
		<comments>http://www.storm-consultancy.com/development/tips-tricks/how-to-nicely-format-compressed-and-minified-javascript-in-chrome/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 09:55:20 +0000</pubDate>
		<dc:creator>Adam Pope</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.storm-consultancy.com/?p=1200</guid>
		<description><![CDATA[I&#8217;ve just found a button that is full of complete win in Chrome.  For years I&#8217;ve struggled to debug problems in jQuery plugins and other people&#8217;s scripts that are served in compressed, minified form.  Not any more! Before The Magical Pretty Print Button After &#160;]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just found a button that is full of complete win in Chrome.  For years I&#8217;ve struggled to debug problems in jQuery plugins and other people&#8217;s scripts that are served in compressed, minified form.  Not any more!</p>
<p><span id="more-1200"></span></p>
<h3>Before</h3>
<p><a href="http://www.storm-consultancy.com/wp-content/uploads/2012/01/Screen-shot-2012-01-26-at-09.33.44.png"><img class="aligncenter size-medium wp-image-1201" title="Compressed and Minified jQuery" src="http://www.storm-consultancy.com/wp-content/uploads/2012/01/Screen-shot-2012-01-26-at-09.33.44-258x300.png" alt="Compressed and Minified jQuery" width="258" height="300" /></a></p>
<h3>The Magical Pretty Print Button</h3>
<p><a href="http://www.storm-consultancy.com/wp-content/uploads/2012/01/Screen-shot-2012-01-26-at-09.34.431.png"><img class="aligncenter size-full wp-image-1203" title="Pretty Print" src="http://www.storm-consultancy.com/wp-content/uploads/2012/01/Screen-shot-2012-01-26-at-09.34.431.png" alt="Pretty Print" width="486" height="180" /></a></p>
<h3>After</h3>
<p><a href="http://www.storm-consultancy.com/wp-content/uploads/2012/01/Screen-shot-2012-01-26-at-09.34.14.png"><img class="aligncenter size-medium wp-image-1202" title="Uncompressed and readable jQuery" src="http://www.storm-consultancy.com/wp-content/uploads/2012/01/Screen-shot-2012-01-26-at-09.34.14-258x300.png" alt="Uncompressed and readable jQuery" width="258" height="300" /></a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.storm-consultancy.com/development/tips-tricks/how-to-nicely-format-compressed-and-minified-javascript-in-chrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading a Rails 3.0 project to Rails 3.1</title>
		<link>http://www.storm-consultancy.com/development/tutorials/upgrading-a-rails-3-0-project-to-rails-3-1/</link>
		<comments>http://www.storm-consultancy.com/development/tutorials/upgrading-a-rails-3-0-project-to-rails-3-1/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 10:47:16 +0000</pubDate>
		<dc:creator>Adam Pope</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.storm-consultancy.com/?p=1108</guid>
		<description><![CDATA[I&#8217;ve just upgraded an old Ruby on Rails 3.0 project to the current 3.1 build.  Having expected ours of pain I was very pleased to discover that it&#8217;s all terribly easy.  Here&#8217;s the step by step (as ever YMMV depending on gems you have installed). Open your gemfile and replace gem &#8216;rails&#8217;, &#8217;3.0.0&#8242; with  gem &#8216;rails&#8217;, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just upgraded an old Ruby on Rails 3.0 project to the current 3.1 build.  Having expected ours of pain I was very pleased to discover that it&#8217;s all terribly easy.  Here&#8217;s the step by step (as ever YMMV depending on gems you have installed).</p>
<p><span id="more-1108"></span></p>
<ol>
<li>Open your gemfile and replace<strong> gem &#8216;rails&#8217;, &#8217;3.0.0&#8242;</strong> with  <strong>gem &#8216;rails&#8217;, &#8217;3.1.3&#8242;</strong>.  3.1.3 being the latest build at the time of writing.</li>
<li>If you want to use the new asset pipeline hotness in 3.1 (and why wouldn&#8217;t you?) you need to add a new section at the bottom of the file:
<pre class="brush:ruby">group :assets do
  gem 'sass-rails', "  ~&gt; 3.1.0"
  gem 'coffee-rails', "~&gt; 3.1.0"
  gem 'uglifier'
end</pre>
</li>
<li>Now open up your command line and run a <strong>bundle install</strong>. You may need to delete gemfile.lock.</li>
<li>The next step is to run rake rails:update.  The first time I did this I got the error &#8220;uninitialized constant ActionView::Helpers::JavaScriptProxy&#8221;.  To resolve this I removed <strong>jrails</strong> from my gemfile as Rails 3.1 uses jQuery anyway.  I then re-ran the rake command.</li>
<li>The Rails update will generate a bunch of conflicts.  I did the following (make sure you use the diff option to check for yourself!):
<ul>
<li>boot.rb &#8211; overwrite.</li>
<li>routes.rb &#8211; do not overwrite.</li>
<li>application.rb &#8211; do not overwrite. We&#8217;ll patch this up manually next.</li>
<li>development.rb &#8211; do not overwrite. You might be able to get away with overwriting this, but I have settings I need in here.</li>
<li>production.rb &#8211; do no overwrite. Again, I have settings I need in here.</li>
<li>test.rb &#8211; overwrite. I didn&#8217;t have any special settings here, but use the diff to check yours!</li>
<li>secret_token.rb &#8211; overwrite.</li>
<li>session_store.rb &#8211; overwrite.</li>
<li>en.yml &#8211; do not overwrite.</li>
</ul>
</li>
<li>Now we need to make a few changes that would have been made if we let Rails overwrite our files. Open up config/application.rb and add the following:
<pre class="brush:ruby"># Enable the asset pipeline
config.assets.enabled = true

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'</pre>
</li>
<li>Open up config/environments/development.rb, remove &#8220;config.action_view.debug_rjs = true&#8221;and add the following:
<pre class="brush:ruby"># Do not compress assets
config.assets.compress = false

# Expands the lines which load the assets
config.assets.debug = true</pre>
</li>
<li>Open up config/environments/production.rb and add:
<pre class="brush:ruby"># Compress JavaScripts and CSS
config.assets.compress = true

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false

# Generate digests for assets URLs
config.assets.digest = true</pre>
</li>
<li>Create a new <strong>assets</strong> folder in <strong>app</strong> and then add <strong>images</strong>, <strong>javascripts</strong> and <strong>stylesheets</strong> and sub-directories.  Move your CSS, JS and image files into these directories.</li>
<li>You&#8217;ll have to do some work to cleanup your assets and how they are included in your layouts &#8211; but that&#8217;s very much an exercise for the reader :)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.storm-consultancy.com/development/tutorials/upgrading-a-rails-3-0-project-to-rails-3-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoffeeScript, SASS and LESS compilation in Visual Studio 2010</title>
		<link>http://www.storm-consultancy.com/development/tools-plugins/coffeescript-sass-and-less-compilation-in-visual-studio-2010/</link>
		<comments>http://www.storm-consultancy.com/development/tools-plugins/coffeescript-sass-and-less-compilation-in-visual-studio-2010/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 10:00:32 +0000</pubDate>
		<dc:creator>Adam Pope</dc:creator>
				<category><![CDATA[Tools & Plugins]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[coffeescript]]></category>
		<category><![CDATA[LESS]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[SASS]]></category>
		<category><![CDATA[SCSS]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.storm-consultancy.com/?p=1053</guid>
		<description><![CDATA[I&#8217;ve been doing most of my development in Ruby on Rails over the past month and have fallen in love with the Asset Pipeline.  This is a process that lets you write in the new, more expressive forms and then compile and serve the raw CSS and JavaScript to the user. The enhancements to CSS that are [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing most of my development in Ruby on Rails over the past month and have fallen in love with the <a href="http://guides.rubyonrails.org/asset_pipeline.html">Asset Pipeline</a>.  This is a process that lets you write in the new, more expressive forms and then compile and serve the raw CSS and JavaScript to the user.</p>
<p>The enhancements to CSS that are found in <a href="http://sass-lang.com/">SASS</a> and <a href="http://lesscss.org/">LESS</a> are simply brilliant and save a massive amount of time.  Variables, nested selectors and mixins are just a few of my personal favourites.  <a href="http://coffeescript.org/">CoffeeScript</a> puts a wonderfully expressive veneer on top of JavaScript, removing lots of the grunt work and making your code much cleaner.</p>
<p>Using these improvements to the everyday languages has become second-nature and I&#8217;d be reluctant to go back.  Think about how much of a difference jQuery made to JavaScript DOM manipulation and animaton &#8211; you just wouldn&#8217;t want to go back to how it used to be!</p>
<p>However, my time is split between the Ruby on Rails world and the ASP.NET MVC world.  .NET doesn&#8217;t have native support for these new languages yet.  What&#8217;s a dev to do?</p>
<p><span id="more-1053"></span></p>
<p>Thankfully, the lovely people of Mindscape have released a <a href="http://visualstudiogallery.msdn.microsoft.com/2b96d16a-c986-4501-8f97-8008f9db141a">free Visual Studio plugin</a> to take our pain away! The plugin handles CoffeeScript, LESS and SASS files, compiling them to native code every time you save your file.</p>
<p><a href="http://www.storm-consultancy.com/wp-content/uploads/2011/12/Screen-shot-2011-12-30-at-16.13.47.png"><img class="aligncenter size-full wp-image-1055" style="border-style: initial; border-color: initial;" title="New files created on save" src="http://www.storm-consultancy.com/wp-content/uploads/2011/12/Screen-shot-2011-12-30-at-16.13.47.png" alt="New files created on save" width="233" height="74" /></a></p>
<p>It also adds new project items types to the &#8216;Add Item&#8217; dialog and provides syntax highlighting within .coffee, .less and .sass files.</p>
<p><a href="http://www.storm-consultancy.com/wp-content/uploads/2011/12/Screen-shot-2011-12-30-at-16.11.39.png"><img class="aligncenter size-full wp-image-1054" title="New files types" src="http://www.storm-consultancy.com/wp-content/uploads/2011/12/Screen-shot-2011-12-30-at-16.11.39.png" alt="File types in Add Item" width="292" height="135" /></a></p>
<p>&nbsp;</p>
<p>Simple and brilliant.  You can still link to your CSS and JavaScript files as you always have in HTML, or, as I do, use a NuGet package like <a href="http://nuget.org/packages/combres">Combres</a> to combine and minify your files to reduce page load time.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.storm-consultancy.com/development/tools-plugins/coffeescript-sass-and-less-compilation-in-visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JQuery &amp; HTML5 Drag n Drop Uploads with ASP.NET MVC3</title>
		<link>http://www.storm-consultancy.com/development/tools-plugins/jquery-html5-drag-n-drop-uploads-with-asp-net-mvc3/</link>
		<comments>http://www.storm-consultancy.com/development/tools-plugins/jquery-html5-drag-n-drop-uploads-with-asp-net-mvc3/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 10:00:56 +0000</pubDate>
		<dc:creator>Adam Pope</dc:creator>
				<category><![CDATA[Tools & Plugins]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://blog2.storm-consultancy.com/blog/?p=703</guid>
		<description><![CDATA[I recently came across this incredibly funky jQuery library to do Drag &#8216;n&#8217; Drop uploads using the new HTML5 File API.  After reading about it and playing with the demo I just had to try it out, so I&#8217;ve knocked up a sample ASP.NET MVC 3 app that handles the uploads.  It currently works in Chrome and [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across this incredibly funky <a href="http://www.igloolab.com/jquery-html5-uploader/">jQuery library to do Drag &#8216;n&#8217; Drop uploads</a> using the new HTML5 File API.  After reading about it and playing with the demo I just had to try it out, so I&#8217;ve knocked up a sample ASP.NET MVC 3 app that handles the uploads.  It currently works in Chrome and Firefox.</p>
<p>You can grab the code for this demo from <a href="https://github.com/stormuk/ASP.NET-MVC3-HTML5-Upload-Demo">GitHub</a>.</p>
<p><span id="more-703"></span></p>
<p>There&#8217;s not a lot to say that the demo doesn&#8217;t show, it&#8217;s all terribly easy to set up.  A minimal example requires a droppable area, e.g. a &lt;div&gt; tag to be on the page with the following JavaScript.</p>
<pre class="brush:javascript">$("#dropbox").html5Uploader({
    name: "myfile",
    postUrl: "/Home/Upload"
}</pre>
<p>The options specify the name of the form field when it&#8217;s POSTed and the URL of the script to POST to. From there you can extend the funkyness by listening for the wide range of events that get bubbled up.  These let you show previews of the files you&#8217;re uploading, show progress bars, let people know when the upload is complete or provide helpful errors when things go wrong.</p>
<p>All in all, it&#8217;s super sexy and really easy to get started with!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.storm-consultancy.com/development/tools-plugins/jquery-html5-drag-n-drop-uploads-with-asp-net-mvc3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirect an entire site with .htaccess but exclude one or more directories</title>
		<link>http://www.storm-consultancy.com/development/code-snippets/redirect-entire-site-with-htaccess-but-exclude-one-or-more-directories/</link>
		<comments>http://www.storm-consultancy.com/development/code-snippets/redirect-entire-site-with-htaccess-but-exclude-one-or-more-directories/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 10:00:33 +0000</pubDate>
		<dc:creator>Adam Pope</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.storm-consultancy.com/blog/development/?p=641</guid>
		<description><![CDATA[We recently wanted to move a website to a new domain and automatically send visitors and Googlebot to the new content, but certain resources had to remain on the current domain.  This meant we needed to redirect all requests to the site, except for the contents of a couple of directories, to a new domain.  After some [...]]]></description>
			<content:encoded><![CDATA[<p>We recently wanted to move a website to a new domain and automatically send visitors and Googlebot to the new content, but certain resources had to remain on the current domain.  This meant we needed to redirect all requests to the site, except for the contents of a couple of directories, to a new domain.  After some head scratching we decided the simplest answer was a RewriteRule in our .htaccess file.</p>
<p><span id="more-641"></span></p>
<p>We used the following mod_rewrite rule:</p>
<pre>RewriteEngine on
RewriteCond %{REQUEST_URI}!^/test/
RewriteCond %{REQUEST_URI}!^/my-folder/
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]</pre>
<p>This redirects (permanently with a 301 redirect) all traffic to the site to http://www.newdomain.com, except requests to resources in the /test and /my-folder directories.  We transfer the user to the exact resource they requested by using the (.*) capture group and then including $1 in the new URL.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.storm-consultancy.com/development/code-snippets/redirect-entire-site-with-htaccess-but-exclude-one-or-more-directories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using App_Offline.htm to take you ASP.NET Web Application Offline</title>
		<link>http://www.storm-consultancy.com/development/tips-tricks/using-app_offline-htm-to-take-you-asp-net-web-application-offline/</link>
		<comments>http://www.storm-consultancy.com/development/tips-tricks/using-app_offline-htm-to-take-you-asp-net-web-application-offline/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 10:00:36 +0000</pubDate>
		<dc:creator>Adam Pope</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.storm-consultancy.com/blog/development/?p=475</guid>
		<description><![CDATA[Ever wanted to stop visitors from seeing your site whilst you performed maintenance to it?  Maybe you&#8217;re having some database or hardware issues and you want to stop any new requests from hammering your server.  Well, with ASP.NET 2.0 and later it&#8217;s as easy as adding a single file to your website. All you have [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to stop visitors from seeing your site whilst you performed maintenance to it?  Maybe you&#8217;re having some database or hardware issues and you want to stop any new requests from hammering your server.  Well, with ASP.NET 2.0 and later it&#8217;s as easy as adding a single file to your website.</p>
<p><span id="more-475"></span></p>
<p>All you have to do is create a file called app_offline.htm in the root of the website.  Bam!  Your site is down for maintenance.  This provides a super convenient way to take your website offline while you make changes to it.  You can put arbitrary HTML in the file, so your offline page can be as pretty (or otherwise) as you like &#8211; with a caveat discussed later.</p>
<p>When ASP.NET sees the app_offline.htm, it will shut down the AppDomain for the application and instead return the  app_offline.htm file in response to all new HTTP requests.  When you&#8217;ve finished deploying your new version, fixing the problem or replacing the hardware, just delete the file and the site will come back online.</p>
<h3>Images, CSS and JavaScript</h3>
<p>When you have an app_offline.htm file it will be returned for EVERY request.  That includes static assets like images, CSS files and JavaScript files.  So, if you want you offline page to be pretty, CSS and JavaScript will have to be inlined.  Images are a bit more tricky but are possible.  You&#8217;ll have to Base-64 encode the image and include it using a <a href="http://en.wikipedia.org/wiki/Data_URI_scheme">data URI</a>.</p>
<h3>Avoiding friendly HTTP errors</h3>
<p>Some browsers like to be helpful to their users and display their own custom error pages for HTTP errors like 404 and 500.  These errors are triggered when the page returned by the server is very short, typically less than 512 bytes.  If you just put the words &#8216;Application Offline&#8217; in your app_offline.htm file then the browser will override it and the user will just think your site is broken.  So, always make sure you page is at least 512 bytes by adding filler tags or hidden text.</p>
<h3>And finally&#8230;</h3>
<p>You could automate the addition and removal of the file as part of your automated deployment script.  You do have an automated deployment script, right?  No?  Remember: automate all of the things!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.storm-consultancy.com/development/tips-tricks/using-app_offline-htm-to-take-you-asp-net-web-application-offline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error messages seen at Storm in 2011</title>
		<link>http://www.storm-consultancy.com/development/musings/error-messages-seen-at-storm-in-2011/</link>
		<comments>http://www.storm-consultancy.com/development/musings/error-messages-seen-at-storm-in-2011/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 12:05:13 +0000</pubDate>
		<dc:creator>Adam Pope</dc:creator>
				<category><![CDATA[Musings]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.storm-consultancy.com/?p=1006</guid>
		<description><![CDATA[We work with a wide range of technologies, frameworks and tools at Storm and that means we&#8217;re working with new things and learning all the time.  As any developer will tell you, there are two critical requirements that make learning a new tool easier: good documentation and good error messages for when you inevitably get [...]]]></description>
			<content:encoded><![CDATA[<p>We work with a wide range of technologies, frameworks and tools at Storm and that means we&#8217;re working with new things and learning all the time.  As any developer will tell you, there are two critical requirements that make learning a new tool easier: good documentation and good error messages for when you inevitably get it wrong.</p>
<p>2011 has been <a href="http://www.storm-consultancy.com/blog/development/musings/2011-a-polyglot-programmers-journey/">a year of many new things</a> and we&#8217;ve seen our fair share of error messages.  Some of which were just a little bit more&#8230;. special&#8230;than others.  We&#8217;d like to share these with you, so that when you&#8217;re writing your next library, toolkit, plugin or whatever, you take time to think about the error messages the mere mortals using your code will see!</p>
<p><span id="more-1006"></span></p>
<h3>&#8220;You don&#8217;t exist.  Go away.&#8221;</h3>
<p>Paul received this error from SSH whilst trying to push a Git commit.  It turned out that a sector of his hard drive had gone rogue and completely borked his terminal session and the rest of OS X&#8217;s authentication.  A restart fixed the problem &#8211; but only after a lot of head scratching and complete bewilderment!</p>
<h3>&#8220;m.&#8221;</h3>
<p>This error was displayed by TortoiseGit after an error occurred pushing to a Git repo.  I can only assume that a bug in the software truncated the error message.  I have absolutely no idea what the error actually was.</p>
<h3>&#8220;The server is unwilling to process your request&#8221;</h3>
<p>&#8220;WELL TRY HARDER!!&#8221; could often be heard coming from my desk as Active Directory returned one of the worst error messages ever written.  The beauty of this error is that is returned for, as far as I can tell, hundreds of different reasons.  From validation errors, to typos in queries, to non-existent attribute names.  I mean really, could somebody at Microsoft not have put just a tiny bit more effort in and returned something slightly more meaningful?</p>
<h3>&#8220;Unknown COM error&#8221;</h3>
<p>My favourite and most often seen error in 2011 as I battled my way through Active Directory.  This takes the prize for least helpful error message of the year.  As with the server being a lazy shit, this error can be returned for hundreds of different reasons.  However, unlike the previous error, this message is paired with a hex code, for example 0&#215;8000500, which when Googled often yielded useful information about the cause of the error &#8211; so not exactly &#8216;Unknown&#8217; then!!!  Could they have not have included that information in the error?!</p>
<p>Did you encounter any cretinous errors in 2011?  We&#8217;d love to hear about them!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.storm-consultancy.com/development/musings/error-messages-seen-at-storm-in-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup email alerts from ELMAH when exceptions are raised</title>
		<link>http://www.storm-consultancy.com/development/tools-plugins/setup-email-alerts-from-elmah-when-exceptions-are-raised/</link>
		<comments>http://www.storm-consultancy.com/development/tools-plugins/setup-email-alerts-from-elmah-when-exceptions-are-raised/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 10:43:37 +0000</pubDate>
		<dc:creator>Adam Pope</dc:creator>
				<category><![CDATA[Tools & Plugins]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Error Logging]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.storm-consultancy.com/blog/development/?p=484</guid>
		<description><![CDATA[This is part of a series of posts on using <a href="http://code.google.com/p/elmah/" target="_blank">ELMAH</a> to handle error logging for your ASP.NET web applications.  We've already looked at how to <a href="http://www.storm-consultancy.com/blog/development/tools-plugins/getting-started-with-elmah-asp-net-error-logging-and-reporting/" target="_blank">get started with ELMAH</a> and how to <a href="http://www.storm-consultancy.com/blog/development/tools-plugins/allowing-secure-remote-access-to-your-elmah-error-log/" target="_blank">allow remote access to your error logs</a>.  In this post we are going to look at how to configure ELMAH to send you an email alert every time an exception occurs on your site.  This is a really handy feature if you want to catch bugs early and keep your site running smoothly.]]></description>
			<content:encoded><![CDATA[<p>This is part of a series of posts on using <a href="http://code.google.com/p/elmah/" target="_blank">ELMAH</a> to handle error logging for your ASP.NET web applications.  We&#8217;ve already looked at how to <a href="http://www.storm-consultancy.com/blog/development/tools-plugins/getting-started-with-elmah-asp-net-error-logging-and-reporting/" target="_blank">get started with ELMAH</a> and how to <a href="http://www.storm-consultancy.com/blog/development/tools-plugins/allowing-secure-remote-access-to-your-elmah-error-log/" target="_blank">allow remote access to your error logs</a>.  In this post we are going to look at how to configure ELMAH to send you an email alert every time an exception occurs on your site.  This is a really handy feature if you want to catch bugs early and keep your site running smoothly.</p>
<p>ELMAH makes sending email alerts really quite simple.  Open up your web.config file and add an <code>errorMail</code> section definition and corresponding <code>errorMail</code> entry as follows:</p>
<pre class="brush:xml">&lt;configSections&gt;
	&lt;sectionGroup name="elmah"&gt;
		&lt;section name="errorLog"
                               requirePermission="false"
                               type="Elmah.ErrorLogSectionHandler, Elmah"/&gt;
		&lt;section name="errorMail"
                                requirePermission="false"
                                type="Elmah.ErrorMailSectionHandler, Elmah"/&gt;
	&lt;/sectionGroup&gt;
&lt;/configSections&gt;

&lt;elmah&gt;
	&lt;errorLog type="Elmah.SQLiteErrorLog, Elmah" connectionStringName="..."/&gt;
	&lt;errorMail from="error@mysite.co.uk" to="bug-report@developer.com"/&gt;
&lt;/elmah&gt;</pre>
<p>You&#8217;ll also need to add a reference to the <code>Elmah.ErrorMailModule</code> in your <code>httpModules</code> section.</p>
<pre class="brush:xml">&lt;system.web&gt;
	&lt;httpModules&gt;
		&lt;add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/&gt;
		&lt;add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/&gt;
	&lt;/httpModules&gt;
&lt;/system.web&gt;</pre>
<p>You will then need to configure an SMTP server for error@mysite.co.uk in your web.config.  You can do this in two ways: inline on the <code>errorMail</code> definition, or in a system.net <code>mailSettings</code> section.  Examples of both are shown below.  Personally, I prefer to use a <code>mailSettings</code> section as I use the SMTP details elsewhere in my applications.</p>
<pre class="brush: xml">&lt;system.net&gt;
    &lt;mailSettings&gt;
		&lt;smtp deliveryMethod="network"&gt;
			&lt;network host="..." port="25" userName="..." password="..." /&gt;
		&lt;/smtp&gt;
    &lt;/mailSettings&gt;
&lt;/system.net&gt;

or

&lt;errorMail from="..." to="..."  async="true" smtpServer="..." smtpPort="25" userName="..." password="..." /&gt;</pre>
<p>If you want to send your error emails using GMail&#8217;s SMTP server you will have to change a couple of bits in your configuration.  GMail requires SSL to be enabled.  We cannot specify this through the system.net section so we need to add the useSsl parameter to the errorMail tag.  We also need to specify port 587.  If you don&#8217;t specify a port on your errorMail tag, ELMAH will use port 25 by defualt.  To tell it to use the port we have defined in the system.net section, set <code>smtpPort="0"</code>. [Thanks to <a href="http://scottonwriting.net/sowBlog/archive/0000/00/00/163350.aspx" target="_blank">Scott Mitchell</a> for this tip]</p>
<pre class="brush:xml">&lt;elmah&gt;
	&lt;errorMail from="..." to="..." async="true" smtpPort="0" useSsl="true" /&gt;
&lt;/elmah&gt;

&lt;system.net&gt;
	&lt;mailSettings&gt;
		&lt;smtp deliveryMethod="network"&gt;
			&lt;network host="smtp.gmail.com"
				 port="587"
				 userName="..."
				 password="..." /&gt;
		&lt;/stmp&gt;
	&lt;/mailSettings&gt;
&lt;/system.net&gt;</pre>
<p>That&#8217;s all you need.  I suggest creating a page with a deliberate error on to check that everything is set up correctly.</p>
<p>What Next?  Well, if you have a team of developers working on a site then you probably have bug tracking software keeping track of problems that need working on.  Most popular bug tracking packages allow you to post issues by email &#8211; why not pipe your error report emails straight into your bug tracker, after all problems that are happening now should be top of your todo list (See <a href="http://www.codinghorror.com/blog/2009/04/exception-driven-development.html" target="_blank">Jeff Atwood&#8217;s Exception-Driven Development</a>).</p>
<p><strong>Caution: </strong>If you experience email issues (maybe a password changes, or an SMTP relay is misconfigured) then you will not receive emails alerting you to the problem (or any other problems).  This is a catch-22 that has caught me out a few times.   If this becomes a problem for you, ELMAH also provides an RSS feed of errors which you could subscribe to, it can also Tweet your errors to you!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.storm-consultancy.com/development/tools-plugins/setup-email-alerts-from-elmah-when-exceptions-are-raised/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Allowing secure, remote access to your ELMAH error log</title>
		<link>http://www.storm-consultancy.com/development/tools-plugins/allowing-secure-remote-access-to-your-elmah-error-log/</link>
		<comments>http://www.storm-consultancy.com/development/tools-plugins/allowing-secure-remote-access-to-your-elmah-error-log/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 10:43:35 +0000</pubDate>
		<dc:creator>Adam Pope</dc:creator>
				<category><![CDATA[Tools & Plugins]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Error Logging]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.storm-consultancy.com/blog/development/?p=482</guid>
		<description><![CDATA[This is part of a series of posts on using <a href="http://code.google.com/p/elmah/" target="_blank">ELMAH</a> to handle error logging for your ASP.NET web applications.  We've already looked at how to <a href="http://www.storm-consultancy.com/blog/development/tools-plugins/getting-started-with-elmah-asp-net-error-logging-and-reporting/" target="_blank">get started with ELMAH</a> and how to <a href="http://www.storm-consultancy.com/blog/development/tools-plugins/setup-email-alerts-from-elmah-when-exceptions-are-raised/" target="_blank">send email alerts when errors occur</a>.  Now we're going to configure remote access to ELMAH's error logs and add authentication so that only permitted users may read our exception details.]]></description>
			<content:encoded><![CDATA[<p>This is part of a series of posts on using <a href="http://code.google.com/p/elmah/" target="_blank">ELMAH</a> to handle error logging for your ASP.NET web applications.  We&#8217;ve already looked at how to <a href="http://www.storm-consultancy.com/blog/development/tools-plugins/getting-started-with-elmah-asp-net-error-logging-and-reporting/" target="_blank">get started with ELMAH</a> and how to <a href="http://www.storm-consultancy.com/blog/development/tools-plugins/setup-email-alerts-from-elmah-when-exceptions-are-raised/" target="_blank">send email alerts when errors occur</a>.  Now we&#8217;re going to configure remote access to ELMAH&#8217;s error logs and add authentication so that only permitted users may read our exception details.</p>
<p>By default, ELMAH is configured to deny access to the error log it produces unless you are accessing it from the server the site is hosted on.  To safely access our logs remotely we need to do two things.  First, we need to enable remote access.  Second, we need to add authentication so that random users and people of ill-intent cannot access our error reports and see sensitive details of the inner workings of our application.</p>
<h3>Enabling Remote Access to ELMAH</h3>
<p>To enable remote access we need to add the <code>security</code> section to ELMAH and set <code>allowRemoteAccess="yes"</code>.</p>
<pre class="brush: xml">&lt;configSections&gt;
	&lt;sectionGroup name="elmah"&gt;
		&lt;section name="errorLog"
				 requirePermission="false"
				 type="Elmah.ErrorLogSectionHandler, Elmah"/&gt;
		&lt;section name="security"
				 requirePermission="false"
				 type="Elmah.SecuritySectionHandler, Elmah"/&gt;
	&lt;/sectionGroup&gt;
&lt;/configSections&gt;

&lt;elmah&gt;
	&lt;errorLog type="Elmah.SQLiteErrorLog, Elmah" connectionStringName="..." /&gt;
	&lt;security allowRemoteAccess="yes" /&gt;
&lt;/elmah&gt;</pre>
<p>With those definitions added anybody can navigate to <code>/elmah.axd</code> and browse through the exceptions that have been logged.  This is clearly a Bad Thing™ as our error logs contain details of how our application works and may even expose usernames and passwords.  So, we need to prevent unauthorized access.</p>
<h3>Add Authentication to ELMAH Error Logs</h3>
<p>Using ASP.NET&#8217;s Membership Provider and in-built authorization system we can deny anonymous access by adding the following definition to our web.config file. It can go anywhere inside the root <code>configuration</code> element.</p>
<pre class="brush: xml">&lt;location path="elmah.axd"&gt;
	&lt;system.web&gt;
		&lt;authorization&gt;
			&lt;deny users="?" /&gt;
		&lt;/authorization&gt;
	&lt;/system.web&gt;
&lt;/location&gt;</pre>
<p>This will allow any authenticated user to view the error log.  If you only want a select group of people to be able to view the log, you could put those users into a &#8216;Developers&#8217; role and use something like:</p>
<pre class="brush: xml">&lt;authorization&gt;
	&lt;allow roles="Developers" /&gt;
	&lt;deny users="*" /&gt;
&lt;/authorization&gt;</pre>
<p>If you are unfamiliar with ASP.NET&#8217;s authentication and authorization features, you might find this <a href="http://support.microsoft.com/kb/316871" target="_blank">Microsoft KB article</a> helpful.</p>
<p>That&#8217;s all there is to it.  By now you should&#8217;ve set up automated error logging, secure access to the reports and configured email alerts which pipe straight into your bug tracking software and it&#8217;s probably taken less than an hour &#8211; how awesome is that!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.storm-consultancy.com/development/tools-plugins/allowing-secure-remote-access-to-your-elmah-error-log/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

