Tuesday, September 4, 2012

MVC3, ActionLinks and Virtual Directories

In my day job, my team has been slowly transitioning to MVC3 from Webforms. With some of the normal transitions of learning the nuances of MVC3 (strict mapping of parameter variable names on posts and gets for one) there have been others that I have come to learn even over a year later after starting.
In particular, I am going to point out extensionless URL's and virtual directories in IIS 5.1. And yes, I said IIS 5.1. Unfortunately our servers are running 2003.
Something that had been bothing me for some time was the problem that when you had a site in a virtual directory, none of the links worked with a simple @HTML.ActionLink(...) call. In general, within a View, if you wanted a simple url link you could do "@Html.ActionLink("LinkName","ControllerName","ActionName") and it would automatically map the URL relatively. The above would turn into "/ControllerName/ActionName".

If the site was hosted in a virtual directory (call it "testSite"), then the above ActionLink would resolve to "/testSite/ControllerName/ActionName".

But after publishing to it, even after adding the Extensionless effect, it would always fail on me. And I always had to resort to other means.

Until today.

Note the Checkbox on the bottom left "Check if file exists". Admittedly I don't know why, but having that checked will create 404 Not Found errors on ActionLinks within virtual directories. Unchecked that and BAM! They are found now!

Saturday, September 1, 2012

Changing focus

My current app in progress was moving along just fine for Windows Phone, but I came to a realization. Windows 8 is right around the corner. I need to focus on the Windows 8 version!

So consider this my official change. Windows 8 app development in full swing!