Technically this isn't specific to ASP.NET MVC at all, that just happens to be how I use Elmah. I started work on an ASP.NET MVC project with certain erroneous preconceived notions. I originally started the database with SQL 2008 in mind because I run Windows 7. An easily accessible staging server used SQL 2005 and it was here that I ran into my first compatibility snag. A database project may be set for an earlier revision but you can't transplant those .bak files and expect them to restore. This is generally 101 level stuff but something I tend to keep in the back of my mind at the worst times.
This staging issue foreshadowed production: the shared hosting company I use is running SQL 2000. Argh! Luckily this process was less painful: I used SQL Publishing Wizard and SQL 2000 in a virtual machine to get the database on the lowest common demoninator. Once in SQL 2000, the backup files will easily restore in any future version of SQL. Because the push to production is so infrequent and changes can be diff'd easier than rebuilt I've settled on a structure of Development: 2005, Staging: 2005, and Production: 2000.
I chose an Elmah version (1.1.11517.2009) that dealt specifically with SQL 2005 but was hopefully new enough to be relative to ASP.NET MVC. Switching to SQL 2000 produced a very minor snag: the database script needed to be downgraded.
Fortunately, and with the help of Google code, I could go back to other revisions of the same file in the Elmah codebase and find a version suited for SQL 2000 dated earlier this year. Here's the diff link to show what changes were made: http://code.google.com/p/elmah/source/diff?spec=svn705&r=643&format=side&path=/trunk/src/Elmah/SQLServer.sql&old_path=/trunk/src/Elmah/SQLServer.sql&old=568. When downgrading to SQL 2000, use the left hand side or you could just download the file.
Update (2019): Since Google Code has long been out of service, Elmah can now be found at https://elmah.github.io/. To get an appropriate SQL 2000 file, you may have to look at v1.0 and v1.1 sources. I would think in 2019 you would likely choose a more recent SQL Server version.
While you are there, you might as well follow the examples given by Scott Mitchell Keeping ELMAH's Error Log Size In Check and Deleting All Records In a Table EXCEPT For the N Most Recently Added Records. Why both? The first prunes any records beyond a date range to keep errors relevant. The second makes sure your database stays small in case of anything that can trigger a large number of records within your date window.
While this post actually has nothing to do with ASP.NET MVC directly, the only common denominator is that I came up with this technique while working on the platform.
To be a true 1:1 copy of the previous website I would be converting to ASP.NET MVC, I had to come up with a way to reintroduce the <blink>
tag to XHTML. While you are perfectly able to use <blink>
it doesn't actually do any blinking in IE8 or Firefox. To show that properly, jQuery comes to the rescue.
The technique is really pretty simple:
<div id="#alertheader">
)setInterval(function() {
jQuery.each(jQuery.browser, function(i) {
if ($.browser.msie) {
$('#alertheader').css({ opacity: '0' }).stop().animate({ opacity: '1' }, "fast", "swing");
}
if ($.browser.mozilla) {
$('#alertheader').stop().animate({ opacity: '1' }, "fast", "swing");
}
});
}, 600);
You should hopefully notice the caveat I ran into immediately. IE and Firefox animate their opacity changes differently so it required special handling. An easy exercise for the reader would be to optimize this code to remove the IE/Mozilla check during the setInterval call.
You can achieve similar results by using a series of .fadeOut(x).fadeIn(x) calls but I had to make sure the sum of all calls didn't become less than the setInterval "loop" or it would blink wildly. The other problem it introduces is when text "fades" it can often look weird in either browser if you use a relatively fast interval. This became a headache very early on.
While I can't take whole credit for the technique, the primary Stack Overflow problem that got me started can be found here: https://stackoverflow.com/questions/1375646/jquery-animate-opacity-doesnt-work-properly-on-ie. In the post the user Eric states that jQuery should handle the opacity support for you. It does. For some reason to produce output I felt was adequate, no one definition would work across both browsers.
I'm still in the process of moving but managed to move the computer + desk. I've moved to a much smaller room but the group of friends is a little more in sync compared to the other living arrangement. I still need to share living with other people which tends to suck in certain directions.
I'll reiterate the obvious: moving sucks. I'm sore. I haven't slept much but I'm thankfully about 80% done. Cleanup is going to suck and thankfully I can take trash to where I am now then dump it at work periodically where they have a bigger trash collector.
The only costs so far have been time and gas money, with a large help from my fiancee Miranda.
I was living with someone who has easily gotten by without the internet for a week. Myself? Not so much. I enjoyed "time off" but as a visual learner that needs to see things in front of him, it became incredibly difficult to walk anyone through anything internet related. I made it a point to be very much a part of a plugged-in culture and that showed how dependent others were on my involvement.
I think most of all at the moment I miss my bed and the ability to just do something on the computer then pass out. I should take the opportunity to break the habit as much as possible though.
I'm currently in the process of moving so from the weekend of January 23rd through as fast as I can move, I'll have limited internet access.
I'll use the free time to create a proper sample project to include all the ideas stirred in the outline I made here: Upcoming ASP.NET MVC posts. I'll try to write up as much as I can from various wifi spots with the intention of getting the bulk of it out within the next week. I'm tired of this being on my To-Do list but moving does have the higher priority at the moment.
Let the withdrawal begin.
Most of this may or may not be relevant to your situation but after completing development, staging, and most of the production implementation of an ASP.NET MVC site I wanted to share some of what I learned.
The majority are one or two-off hacks from someone else's code or a down/upgrade where appropriate, creating a Frankenstein. These won't necessarily be in order I don't think.
Elmah
ELMAH_LogError
stored procedure to SQL 2000ELMAH_LogError
pruning taken from 2 blog posts from a single sourcejQuery uses
Areas
SQL 2000 from 2005
MsBuild scripts - dependency chaining, SqlPubWiz integration via Community Tasks, etc.
I'll try to refer to this verbatim as my defacto outline and even that isn't quite structured correctly enough. It'll work itself out as the posts are made I'm sure. I'm using this to hopefully keep me motivated to completing them all.