Posts Tagged ‘web-application’
Putting your ASP.NET Web Application in Maintenance Mode (using ISAPI_Rewrite)
Prompted by @slace’s tweet:
i wish there was a way to use app_offline but still view from certain ip’s
I replied with a suggestion that we’ve used in the past. Aaron said I should blog about it… so here I am (again)!
A while ago we needed to do an Umbraco upgrade (from v3 to v4) on a production server – in my opinion it was a pretty major upgrade on a live site, we had done a couple of test upgrades on dev and staging, all was successful. But since there was various parts of the site that we need to regression test, I felt it best to take the entire site offline whilst we upgraded.
Usually creating an “App_Offline.htm” page in the root of your web app is enough to take it offline. However that was no good for testing… so what to do?
This is where ISAPI_Rewrite is your best friend, (or .htaccess to be precise). We needed to configure the site to allow access for us and redirect everyone else to a “Site under maintenance” page. I found a few examples across the web, but to save you all that hassle, here are the .htaccess rules that we use:
# BEGIN Maintanence Mode
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/offline.html$
RewriteCond %{REMOTE_ADDR} !^82\.13\.23\.230$
RewriteRule ^(.*)$ /offline.html [R=302,L]
</IfModule>
# END Maintanence Mode
What does it do? The first “RewriteCond” rule checks that you are not requesting the “offline.html” page (otherwise you would end up in a constant loop!) The second “RewriteCond” checks the IP address of the visitor – in my case it was “82.13.23.230″ (remember to escape the dots). If those two rules aren’t satisfied, then the “RewriteRule” is used, redirecting the visitor to the “offline.html” page.
As always, I am open to any suggestions or improvements!
Converting CSV to XML
There’s a bit a functionality on one of the projects that I’m working on where I need to do a lookup. The data I’ve been given is in an Excel spreadsheet – which I needed to convert to XML (as ultimately the data will be stored in a CMS that handles XML better).
I’ve done a lot of projects where I need to convert XML to Excel (via CSV), but not many where I need to convert the other way.
I first saved the Excel as an “XML Spreadsheet” – which spat out all sorts of extra MS Office namespaces, styles, etc. Which is fine if I want to re-open the data in Excel. But I wanted the data to be cleaner (and more semantic).
I exported the Excel out as a CSV; then looked for a way to convert it to XML.
Then I found this very useful web-app tool: CSV to XML Converter by Creativyst
It did exactly what I needed! The tool has a 100Kb limit – which was great, because my CSV was 96Kb!
The outputted XML was around 450Kb – which got me thinking… if a lot of developers use that tool the way I did – then that’s a lot of load on their web-server! Maybe that’s where the new Google App Engine could come in handy?! They have the processing power and bandwidth to handle high usage!
I’d love to see other online text conversion utilities … you never know, maybe they could be all centralised on Google Apps?
Mozilla Prism – Bringing Web Apps to the Desktop
I feel like I’ve been living under a rock for the last couple of months. I’ve only just heard about Mozilla’s Prism – and it’s already changing the way I use web-apps.
Prism, (previously called WebRunner), is essentially a Site Specific Browser (SSB) – meaning that it’s a desktop application designed to host a single web-application. This is good for many reasons, foremost it causes less distractions.
So far, I have prisms set-up for most of the Google apps that I regularly use: Google Mail, Google Calendar and Google Reader. Now each of these web-applications are not open as separate tabs in my Firefox, but as individual desktop applications. (Now I don’t have to worry about finding my Gmail tab in Firefox, nor about browser-crashes.)
It reminds of Microsoft attempted to do with HTA – but it seemed more difficult to interface them with external web-applications.
You can read more about Mozilla Prism on their Lab’s blog. [http://labs.mozilla.com/2007/10/prism/]


