The Joy of Learning

It's no secret to people that know me that I despise Microsoft. I've often said that I would vote Republican before I would use Microsoft. Neither are on the horizon. However, this targeted incursion into MS territory is really joyful. I still dislike just about everything I have seen about Windows. Except for the fact that Visual Studio runs in it, I would never touch the stuff. I don't feel so much about .NET. It's got some really clunky things going on. There is a lightness to php (!!) that is sorely missed. .NET mediates everything between me and the web so I end up feeling a little like I'm losing my identity as a programmer. Forget about code strategies, just use learn the damn Server Controls!

Realistically though, it's just a different style of programing language. I used Cake PHP for a recent job and it had php objects that want to stand between me and my web pages, too. The people that specified Cake for the project rightly felt that productivity, uniformity and portability would be increased with Cake. Those are all things that try to steal your identity as a programmer, too. Of course, they also free you to focus on other things.

All is to say, my descent into .NET is really just what it claims to be, a new programming language and environment. Like any learning experience, there are things that are no fun to learn. However, one of the things that is thrilling me these days is the sheer brain exercise of learning. A guy whose blog I read with deeply mixed feelings, Dave Winer, switched from his long-time Mac use to Windows in a fit of pique a few years ago (he's since switched back). He wrote that he was thrilled by the exercise of new neuron paths. I'm with him all the way.

I love the large body of unknown information that I am required/empowered to master. The experimentation documented the other day and the one I'm embarking on this afternoon or Monday (connect to MS SQL) are just plain fun. And there are a billion more. And, once those are done, I get to do even more because, for me, at least, that's what programming is all about. I look at where I am, decide what is missing (or ask the BA) and then find a way to make it better. It's exploration and experimentation and, eventually, polishing and putting a bow on something cool.

Go out and learn something. It's worth it.

Recap of getting a virtual host equivalent (host header) working on Windows 7 with IIS7

1) Make a website. I think you can use something as simple as a folder with Default.aspx (containing regular html). Maybe there are other file types. That will be tomorrow's challenge.

2) Add IUSR to its permissions with Properties->Security->edit->add->enter object name->full permissions. UPDATE: it's a week or so later. I just added a new local host to my computer. It wouldn't work until I also added IIS_IUSRS. Apparently both are needed.

3) Go to IIS7 manager (control panel->administrative tools->IIS), click the outline in the left column until you see Sites. Right-click->Properties->add website. Enter things like I showed in the screen shot of the first post.

4) Edit C:\\system32\drivers\etc\hosts with Notepad in admin mode. Add a line like " www.sandbox.local" and save. It turns out that this is effective immediately.

5) Try the site.

6) Scream Eureka and make a cocktail. Accomplishment has been achieved.

Granting permissions for IIS7

I know that permissions are done in Windows through Properties (the equivalent of Macintosh 'Get Info'), so I used that. It offers a Securites tab and that shows a bunch of user type things and their permissions. None of them are say IIS_IUSRS.

I clicked Edit. Then I clicked Add. Seems easy but, what do I do then? Eventually, I pasted the value into the 'Enter Object Names' (a permission object?) and clicked a button called Check Name. It revised the string to include the server name. Eureka! It recognized it and did something sensible. Save save save. Try the website. Nope. But, it was Nope with a different error message. That spells progress.

The error message was now a 403.1 talking about access control, etc. I googled it ("windows 7" directory or page because of the access control list (ACL) configuration or encryption settings) and found a page that instructed me on how to set the IIS user. It basically comes down to finding that Authentication icon in the IIS7 manager, finding the site (sandbox) and checking out its Properties (right-click Properties is used for everything!). That page suggested I change the user to match my permissions but, seeing the user that was automatically set, IUSR, I thought, I'd add that to the permissions for Visual Studio's directory.

And that, my friends, did the job.

Trying to get websites to work on IIS7

See? We have another search friendly term. Turns out that google responds nicely to "IIS7". Also, I have found much better results when I quote "Windows 7" for google. It causes the search engine to treat that as a single word instead of giving me every page that has the word 'windows' in it. Enjoy.

The permissions thing I thought about last night is not the answer. The binding for localhost has the exact same permissions issues and it works just fine. I guess I'd rather this was the problem but, what the heck, at least it's another issue off the list.

Next, I am trying to figure out how to debug IIS7 in general. I looked at the places it appears to offer log files. Not much there.

Then, I got the idea to see if I could ping the site name (www.sandbox.local) from my command line. Localhost works. Sandbox, not so much. It "could not find host". Looking around, google showed me a guy named Mike Volodarsky. Check him out. He has some good-looking info on his site. Among those is a page specific to IIS7 server not found. Reading it, it became clear that my problem resembles a DNS failure. In localhost terms, that means that Windows 7 has the equivalent of the unix hosts file. 

In fact, it has exactly that. I dug through and found a wikipedia page that talks all about hosts files. For Windows 7 (and most other modern MS operating systems), the hosts file is at C:\system32\drivers\etc\hosts. Off I go but, notepad won't see it. Arrrgh! It's hidden. Open. Can't save. Arrrgh! Since I am running underneath of OSX and not serving outside my environment, I just changed the permissions to let any authorized user (aka, me) have full priveleges. Voila!

I entered:    *.sandbox.local

Save. Great hopes. Nope. Ping still says no such host. Have I said, Arrrgh! lately?

I tried restarting IIS7 by selecting my new entry in the manager and clicking restart. No dice. This makes no sense.

Obviously, time for reboot.

And ping works. And firefox shows me the next layer of this stinky onion.

"Cannot read configuration file due to insufficient permissions" from IIS Web Core.

Along the way, I found that there is an 'Authentication' icon that offers, among other things, "Anonymous Authentication". This is enabled. Not the problem, but good to know about.

I found somebody who has exactly this problem, including the fact that he's trying to run his website out of his Documents folder. He says, "To fix this problem, we need to grant the read permission to IIS_IUSRS on ‘httdocs’ folder." Ok. How?

Apache Virtual Hosts == IIS Host Headers

I learned this fact, after substantial research, from Microsoft itself.

So, I am trying to make this work. First, I fired up Visual Studio and created a new project, Hello World!! I tell it to show me the site, it calls the web browser with a long port number, ie, localhost:1234859. It works. Life is good.

I head over the IIS control panel, following the instructions. The basic premise is that you find an item called Sites, tell it to add a new one, and enter some info. I take a look at the default website and figure out what folder to refer to. After a couple of tries, I have an item that looks mighty good.

I try it and get "Firefox can't find the server at www.sandbox.local."

Thinking that there might be something wrong with my site, I revise the entry to point to inetpub/wwwroot.  No dice. Lots of other random stuff. No dice.

There is something called "Pass Through Authentication" which has a 'Test" button on the configurator. It doesn't pass. I think that, tomorrow, I will investigate this.

My First Posterous Post

I have been a LAMP (Linux, Apache, Mysql, PHP) programmer for a decade. I have a lot of habits and experience in those technologies. I'm also a Macintosh person and have been since 1984. I despise Microsoft.

I was looking for a job. I found one writing an application type of website. It's supposed to be a new platform based on the best technologies, preferring open source. I got the job by discussing OO and MVC and ORM and AJAX and LSB and a whole gibberish full of things that I had been studying while I was out of work. An incredible opportunity to do something extremely cool.

Imagine my distress when I found that the new system is to be written using Microsoft technologies. 

The opportunity is too good to refuse, or perhaps more accurately, chicken out of. Lots of people really like .NET. I'm sure there are lots of ways in which they are right. In any case, I'm going to do it and, by the end of 2010, I am going to be a serious .NET programmer.

I've been working here for about six weeks, mostly studying the problem domain and helping to write the proposal. I've done some studying on the platform components and will explain that later. I have spent today installing Parallels on my Macintosh and then Windows 7 in Parallels. And then Visual Studio in WIndows. Then IIS. Amazing how many details and how many hours it takes.

Anyway, I was trying to figure out how to do virtual hosting so that I could have some sandboxes to play with in my new environment. After a bunch of frustrated googling, I found that IIS doesn't do virtual hosts. It does "host headers." Same idea. Different words. When I run into a situation where there is divergent terminology, I often think that it would be nice if someone used both terms in an article that google could propose to me. Then I realized, I am at the very beginning of an interesting experience that begs to be documented.

And so, if I have the patience, this will become a repository of my learnings as I add .NET, C#, ASP.NET 3.5, ASP.NET MVC, ASP.NET AJAX, Sproutcore, nHibernate, Visual Studio, and heaven only knows what else to my brain box.

I hope it's fun.