Archive

Archive for June, 2008

[REPOST] – Deploying ASP.NET MVC on IIS6.0

June 6, 2008 2 comments

Last week, I finally got the ball rolling on our IIS server. With a little help from a friend, I managed to get the SSL Certificate installed. A quick tutorial, and the site was moved to the server but it would not respond. Monday, I managed to get the site to respond by installing the .NET 3.5 framework on the server and I mistakenly thought it was up and running, so I released it to the beta testers. Of course, immediately the testers informed me that only the home page was showing, while all other links returned a 404 message.

I went through several efforts and can now happily say that it does work, so I am officially saying it is deployed. It is far from finished, but it is live on the web (sorry, I can’t share the address at this time). Here are the steps I followed that got it running:

  1. Install .Net Framework 3.5 on IIS Server
  2. Change Route URLs in Global.aspx.cs to include the .mvc extension (this is in the comments for that file)
  3. Install ASP.NET MVC Preview 2 on the IIS Server.
  4. Add an ISAPI extension to the application for .mvc that points to “c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll”.
  5. Uncheck the “Verify that file exists” box on the Extensions configuration dialog.

The last one is what finally made all the pieces fall into place. I don’t know if it is a “DUH” sort of a thing, but you have to remember that I am not an IIS or ASP.NET guy.

I found information on all but the last entry scattered across the web. Hopefully by putting them all in one place it will help some poor wayward soul in the future. According to those resources, these steps should also work for IIS7 in classic mode (integration mode? are those the same?) but should be unnecessary in the default IIS7 configuration.

At any rate, it lives!

Categories: ASP.NET MVC

[REPOST] – Geeking on a Saturday

June 6, 2008 Comments off

In a recent post entitled I am a Professional Geek, I mentioned that I only geek at work. Well, Saturday I had the opportunity to prove just how deep that particular Rabbit hole goes… I gave a presentation on .NET 3.5 Language Enhancements at the Richmond Code Camp Saturday morning, and boy did I stink! I really had trouble focusing my message and expressing myself. I was live coding and kept screwing up the syntax (to those attending, I was missing the delegate keyword on the Local Methods demonstration). We have a tendency to judge ourselves harshly, so I can only hope that the attendees didn’t think it went as poorly as I felt.

I guess every one has off days: Babe Ruth struck out a lot and Edison found 2,000 ways not to make a light bulb. Even Einstein stank up the joint on occasion (read about “The Ether” sometime). Not that I am Einstein, Edison, or Ruth: clearly I’m not. But I believe it is important to give ourselves these pep talks when we mess up. Let’s face it: as programmers, we mess up a lot!

So what’s the lesson? For me it is that weekends and technology don’t mix. Hopefully I can redeem myself in June when I will be presenting at RVNUG on ASP.NET MVC. At least that is during the week!

Categories: Miscellaneous

[REPOST] – Of Mice and Men(tors)

June 6, 2008 Comments off

Just a weekly update…

When I bought this machine, I picked up a new wireless mouse and keyboard. About a week ago, I noticed that my mouse had a flashing red light on it. I had never seen it before, and I quickly realized that this is a battery low indicator light. I had mixed feelings about this. First, I appreciate the notice, because there is nothing more frustrating than being deep in the zone and the mouse or keyboard runs out of power. But when I got to thinking about it, I thought that in a way it is foolish. Just when the power is getting low, you add an additional energy draw by powering a flashing light! I even went around the office showing everyone and commenting about how dumb it was. I likened it to the bank drawing an overdraft charge when you bounce a check. Hello! The problem is there is no money in there in the first place! <sheesh>

Well, today it finally died… right in the middle of a great coding session. Naturally, I was annoyed, both at the interruption and (sheepishly) at the realization that I should have obeyed the warning and replaced the stinking batteries. But I did learn two things: first, the light flashed for over a week before the batteries finally died, and second I learned that the mouse will function on a single battery (which I discovered when I was replacing the batteries). Interesting.

On the Mentor side (to make the title work), I will be giving my “.NET 3.5 Language Enhancements” presentation tomorrow morning at the Richmond Code Camp. Unfortunately I’ll be driving in and immediately driving out and will miss some of the presentations I would like to see. If you see me there, mention the blog and say hello.

Categories: Miscellaneous

[REPOST] – Creating Local Methods with Func

June 6, 2008 Comments off

I wrote briefly about the new Func generic delegate in Part 3 of the Upgrade your C# Skills series. Today, I wanted to explore this in a little more detail.

I’m sure that most of us have created many private methods to outsource code from one method to another. There are times we do this even when the method is only called from a single location. I’m going to use a simple example, but I think you’ll get the point:

foreach (Person person in people)
{DateTime now = DateTime.Now;
int age = now.Year – person.Age;

Console.WriteLine(“{0} {1} was probably born in {2}.”,
person.FirstName,
person.LastName,
age);
}

Kind of a silly example, but fairly straight forward stuff, right? Well, what if we had two loops or other calculations in the same method that needed to know the Year born? Since we believe in code reuse, we would typically throw this into its own private method:

foreach (Person person in people)
{
Console.WriteLine(“{0} {1} was probably born in {2}.”,
person.FirstName,
person.LastName,
CalculateYearBorn(person));
}

privateint CalculateYearBorn(Person person)
{
DateTime now = DateTime.Now;
int age = now.Year – person.Age;
return age;
}

This should be code we can all relate to, and is a fine practice because it accomplishes two very important things. First, it promotes code reuse. Second, it simplifies and cleans up our logic. What unfortunately happens quite frequently is that the outsourced method is only called from one other method, even if it is multiple times. In this scenario, what we really need is a Local Method.

Local Methods

I don’t know if anyone else has coined this phrase before in this context, but it seems appropriate. A quick google search turned up several references to Java and some statistical analysis looking items. Adding the “C#” to the search terms found a couple of references where the term is misapplied to mean a private class method. To be clear, though, what I mean by Local Method is a method defined completely within a non-class parent scope. If you think about it, that’s what Anonymous Delegates are, but unlike an anonymous delegate, we need to be able to assign our method a name. The Func<> Generic Delegate can be used to accomplish this goal.

This approach is going to give us the best of both worlds. First, it is going to allow us to reuse code. Second, it is going to clean up our execution logic by replacing some of it (or maybe even all of it) with a method call. Finally, it is going to help reduce “Class clutter” by eliminating private methods that are only called from one location.

Creating and Using the Local Method

In order to use the local method, we first need to define it as a local variable. This local variable is of type Func<>, which has several different signatures. We are going to use Func<Person, int> to create a method that accepts a Person object as a parameter and returns an int:

Func<Person, int> CalculateYearBorn = new Func<Person,int>(
delegate (Person per)
{
DateTime now = DateTime.Now;
int age = now.Year – per.Age;
return age;
});

Now, to use the local method, we simply call it like we would any other:

foreach (Person person in people)
{
Console.WriteLine(“{0} {1} was probably born in {2}.”,
person.FirstName,
person.LastName,
CalculateYearBorn(person));
}

I think you’ll agree that this is pretty cool and could be very useful. And of course, since this is based on a Generic Delegate, we can use Lambda Expressions to write our code. So even though this is a fairly silly example, let’s go ahead and clean it up a bit:

Func<Person, int> CalculateYearBorn =
new Func<Person, int>(per => { return DateTime.Now.Year – per.Age; });people.ForEach(person => Console.WriteLine(“{0} {1} was probably born in {2}.”,
person.FirstName,
person.LastName,
CalculateYearBorn(person)));

Some Final Notes

I really like this approach, but it naturally does not suit every purpose, so rule one, to paraphrase Sean Connery in The Untouchables, “don’t bring a knife to a gun fight.” In other words, don’t go crazy and use this just because you can. Use it to minimize repeated code within a specific method or to simplify complex code blocks.

There are a couple of additional things you should know. First, you must define the delegate and method details before using them, otherwise the compiler will complain. Second, since this is a local method it has complete access to the other local method variables: this should help reduce the number of parameters you must send in order to accomplish your task. Finally, since the local method is actually a local variable itself, you should be able to change the address dynamically to other delegates. I don’t think I would recommend this last item, but it could prove to be interesting experimentation fodder.

Categories: .NET 3.5

[REPOST] – WordPress 2.5 Blank Page Issue

June 6, 2008 3 comments

You may have experienced an odd occurrence on the site today, and if so I apologize. For some inexplicable reason, the site encountered the dreaded WordPress Blank Page issue. Last I checked, which I think was yesterday afternoon, the site loaded just fine. Today, however, I noticed that the front page would not load. The index.php page produced only a blank return: a completely empty HTML document. Then I confirmed that the Admin page would load correctly.

I checked and even restarted the web server: all was well and restarting did not help, which I expected since all the other sites seemed fine. Next, I deactivated all the plugins, but since that made no difference I reactivated them immediately. I then tried reloading 2.5, but that did not change anything. Finally, I went to the admin page and changed the Theme to the WordPress Default. All of a sudden, the site showed up. I changed back to the regular site theme, and sure enough it would not load. Fortunately, I keep a copy of the Theme on my PC, so I uploaded it again and the site came back.

After going through this, I think I’ve done this once before. Maybe next time I’ll remember the solution without all the gyrations. Of course, it would be nice to not have the problem ever again. I expect to potentially have this sort of problem immediately following an update, but since it has been a couple of weeks since upgrading to 2.5 I really don’t understand the sudden problem.

Categories: This Site

[REPOST] – GMail is Hiring

June 6, 2008 Comments off

Since Jon Skeet recently announced he is joining Google, I thought it was worth mentioning that the GMail Team is hiring. I’ve wondered several times in the past what it would be like to work at Google. I think the truth is that I’m not geeky enough, but I would probably enjoy it while it lasted.

GMail in particular would be of interest to me. I’ve been on the GMail bandwagon since it was in Beta (oh wait… it still is…) OK, I mean since it was really Beta, like fresh and new type beta. I have been purely GMail since 2004 and I have never looked back. I have even succeeded in getting my friends, spouse, parents, and coworkers to convert to GMail as well.

I have a friend who is very SEO savvy, and he shared with me some of the Google interview questions, and all I can remember is that it would have put a Mensa candidate to shame. So since I’m not smart enough to even apply, I’ll just sit on the sidelines and continue be a happy consumer.

Categories: Miscellaneous

[REPOST] – I am a Professional Geek

June 6, 2008 Comments off

I was just reading Payton Byrd’s recent post about the two types of programmers, which references another post about the same topic by Jeff Atwood, and I felt encouraged to respond.

Growing Up ABM

I honestly couldn’t care less about the open-source vs. Microsoft wars. My background is probably atypical, but I as a young programmer I was raised on IBM technologies. As a result, I spent many years as an ABM-er (Anyone But Microsoft). While thinly-veiled by necessity, IBM has embraced this philosophy since the OS/2 debacle. So much so, in fact, that they have donated billions of dollars to Linux, Java, Rational, and Eclipse. To this day there are a great many IBM oriented developers who will do anything to avoid Microsoft solutions, no matter how painful or inconvenient. I know because until 2003 I was one of them.

Being anti-Microsoft meant that I had the opportunity to learn a great many things that I otherwise may not have been motivated to learn: PHP, Linux, Apache, Java, OpenOffice, etc. all fall into that category. I even used a Linux Desktop for almost 2 years just to be as anti-Microsoft as I could. It was during this period that a friend of mine, a TRUE Linux geek from v1, introduced me to VB6. I watched as he created a GUI prototype in minutes that would have taken me days in Swing. When .NET came out, I started seriously paying attention, and by the time VS2003 came out I was hooked.

Technology Agnostic

Today, while I spend most of my time in .NET, it is not unusual for me to spend time in SEU coding RPG on the iSeries or VI coding PHP on a Linux Server. My projects span several different databases with DB2, MySQL, and SqlServer being the most common. I write and maintain Green Screen programs, Windows applications, and Web sites.

The point of all this is to show that I have gone from an ABM Religious Zealot to a true Technology Agnostic. I think that all these people who have “taken sides” got it all wrong. My zealotry is now limited to using the right tool for the right job. I will admit, that these days this usually means Microsoft, but at the same time it could be open source. It could be Linux, it could be IBM, it could be just about anything.
In other words, I just don’t care: I want to get the job done, effectively and with a pleasing result (even if only to me.)

So what am I? I am a Professional Geek

So what struck me about these articles and this general discussion was the question: what am I? In reading about the 20% Alpha Geeks and the 80% Vocational Programmers, I realized that I am really neither. Payton essentially draws the same conclusion, but does so from a much different personal (professional?) viewpoint than I do.

I will definitely say that I am NOT a 20% Alpha Geek. I don’t contribute to Open Source projects or spend my evenings bit twiddling. In fact, I don’t even own a computer. I have often said to people that “I am a professional Geek: I only Geek at work.” After spending most of my working time staring at 2 computer monitors, sitting on my butt in my desk chair, with my fingers glued to the keyboard, the last thing I want to with my free time is spend it on a computer.

But to lump me in with the 80%-ers (by their definition, not mine) would be unfair. I stay ahead of my peers. I read about programming and development incessantly (and occasionally I will read at home). I spend a lot of time learning new technologies and new techniques. I go to trade shows. I participate in User Groups. I write, I teach, and I give presentations. I even give software away. In other words, I am not just “vocational”: I learn, grow, and contribute to our community at large. And I am content with my position, meaning that I recognize I will never be on the level of many of the other developers out there whom I admire, but I still have something to offer so I choose to do so.

50%-ers of the world unite… or don’t…

And so I find myself in neither category, so I’ll just split the middle and say I am a “50%-er”, and I’ll bet most of you are as well. Chime in and rate yourself below – or don’t… it does not matter to me.

Categories: Miscellaneous
Follow

Get every new post delivered to your Inbox.