Monday, April 16, 2012

My first ASP.NET application/Masterpage

I had been having a few issues when attempting to get asp.net applications working on my web server - not knowing much of anything about asp.net, I was under the assumption it would be similar to the ColdFusion I am used to; it was not.

The thing I didn't understand, which this entry exists to remind me (and potentially any youse out there), is AppPools.  IIS seems to by default assign your web root to an appPool - the default (at least for me) being .NET framework 2.0.  It is as simple as changing the Default website to a new appPool using the 4.0 framework right?  Almost...

Having changed the default appPool to 4.0 framework I was now successfully compiling the standard "Hello World" .aspx - but getting run-time errors when attempting to integrate a master page into my site.  A master-page is a 'template' of sorts that can be used to create similar layout/functionality across numerous sites.  The run-time error was explaining that my MasterPage.master could not be found at ~/MasterPage.master - but it was there!

Luckily my wife Kristen was there (who does know ASP.net) to let me know that if I have my application within a directory in of itself, but the application is set up in a separate directory, then the "~/MasterPage.master" reference is relative to the application, not necessarily the directory that you are working in.

Simple fix?  Create a new application pool on the directory where my code is actually hosted.  Yay! Now everything is working without run time errors!