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.
I've recently switched hosting providers at the company I work for. Instead of being able to use wildcard mapping or the .mvc file extension mapping, I'm left with .aspx.
The premise of this exercise is easily explained here: http://www.asp.net/learn/mvc/tutorial-08-cs.aspx, specifically Listing #3 under the Hosted Server section.
While this is fine for a default MVC1 project, I've currently implemented Phil Haack's Areas v1 prototype with Steve Sanderson's CreateArea extension method located here http://blog.codeville.net/2008/11/05/app-areas-in-aspnet-mvc-take-2/.
To make the Global.asax change from Listing #3 in the first link (phew), you need to modify all routes to add the .aspx extension. The same goes true for .mvc.
I followed Steve's example verbatim and eliminated the default "" (blank) route because isn't necessary in wildcard mapping. What isn't readily apparent is that you absolutely need this when you do get into file extensions.
The fix is a simple but because it felt like the same route/area I didn't think it would work.
routes.CreateArea("Root", "Namespace.Controllers",
routes.MapRoute(null, string.Empty,
new { controller = "Home", action = "Index", id = string.Empty })
);
RouteDebug confirmed it gets hit properly so that should be all you need. I haven't tested to see whether you can just add this route and leave it for both file extension and wildcard mapping but it shouldn't be a problem to just add it and leave it.