April 2006 - Posts
In my ever-changing trek through .Net custom build actions (frighteningly similar to the old Friday the 13th Nintendo game, where you just keep moving through a maze of rooms in a log cabin, until Jason pops out and scares you so badly you have to pee, but are too scared to walk down the hall...I was a wuss, so I stuck with Excitebike...but back to the task:), I discovered I needed to pull some environment variables to correctly concatenate each system's path to the .net aspnet_regiis.exe program. I was hitting an issue with some machines having their Microsoft.Net folder under C:\windows, others under C:\winnt, depending on the OS. An easy fix, here's a method to return to you the value of each system's environment variable(s):
Pass a string representing and environment variable, such as: GetEnvironmentVariable("%SystemRoot%");
private void GetEnvironmentVariable(string environmentVariable)
{
string returnValue = string.Empty;
string query = string.Format("your system variable is {0}", environmentVariable);
// replace input string with environment variable value(s)
returnValue = Environment.ExpandEnvironmentVariables(query);
return returnValue;
}
This will output: "your system variable is C:\Windows". How easy is that? <g>
Just a quick note on manipulating IIS virtual directories from .NET code:
I was writing a Custom Action class for my solution's web setup project, and was not sure how to best go about removing the already created virtual directory on Rollback or Uninstall. I at first looked at Windows Server 2003's IISDIR utility, or using IIS's Admin scripts .vbs files located at C:\inetpub\Adminscripts, but these solutions weren't providing me the cross-operating system solution I required.
I came across this post referring to a under-used namespace: System.DirectoryServices. You'll have to add reference to the System.DirectoryServices.dll for your project. After I discovered this, creating and deleting virtual directories from the IIS MetaBase.bin file is a snap:
/// <summary>
/// Remove Virtual Directory from IIS.
/// </summary>
/// <param name="VirtualDirName"></param>
private void DeleteVirtualDirectory(string VirtualDirName)
{
DirectoryEntry Parent = new DirectoryEntry(@"IIS://localhost/W3SVC/1/Root");
Object[] Parameters = { "IIsWebVirtualDir", VirtualDirName };
Parent.Invoke("Delete", Parameters);
}
I'm planning on posting a few more custom action install tips very shortly, stay tuned.
steve
Ah, becoming app_offline.htm experts, one gotcha at a time...Curtis first posted about this file, so I figured I could add in my 2 cents:
I was creating an App_Offline.htm file for our latest web app, and noticed that once I uploaded the file, it was working well....TOO well. Every file I requested returned a 404 File Not Found error. As we all know, getting the task done and conveying this to the user are not always the same thing.
A quick overview: Uploading a basic file named App_Offline.htm to you website's root folder will cause an ASP.NET web application to stop processing requests, and dumps the application domain. This technique is a great, yet little known, feature of asp.net 2.0. Using this temporary file allows for clean website maintenance, including switching out .mdf database files, or changing web content while users are not requesting pages. All this is fine and good, but an Enterprise-class website can't just spew 404 file not founds...elite sites need to handle everything as if they expected it to happen all along...
The gotcha: My App_Offline.htm file contained valid markup, but was still tossing File Not Found errors instead of my nice little message to the user...here's my file:
<html>
<body>
<p>
The Uber Noob Website is temporarily down for scheduled maintenance.
Please check back soon.
</p>
</body>
</html>
The Fix: Internet Explorer has a default setting to display friendly error messages. This trumps our tiny little file, and displays the 404 error instead. IE will behave this way for files smaller than 512 bytes, so the quick fix is to just add a block of commented code to the App_Offiline.htm file, in order to increase the file's size to > 512 bytes:
<!--
This is commented markup, I'm trying to increase file size
This is commented markup, I'm trying to increase file size
This is commented markup, I'm trying to increase file size
-->
Once you are closer to deployment, you can always remove this and replace it with relevant text and formatting to match your site's design, which will get you over the 512b barrier.
here's the link Curtis originally posted, from Guthrie's blog.
Finally, after 3 years, I've broken down and purchased a new cell phone...I went with the Samsung T809 from letstalk.com. So far, I really love the display and the features of this phone...the phone's display is the best I've seen, and this weekend I compared this phone to a buddy's new Razr, and the t809 was so much brighter and sharper that I caught a quick whiff of buyer's remorse before he managed to recover.
Things I like about this phone:
The MP3 player is pretty solid, (the external speaker isn't great, but I only use headphones)
The video resolution is really impressive
Web surfing via T-Zones is surprisingly simple, and mostly unannoying
Expandable microSD slot for large amounts of file storage
USB access as both stright file acess, or modem mode for direct interaction
1.3 MPixel camera is solid, but not amazing
Video recording is decent
Menus are easily accessible
Display is completely customizable
Things I don't like:
Complete reliance on non-standard jack, for USB access, headphones, power supply, etc
Headphones are basic, and require adapter to non-standard format
Included games hung on my phone twice in first week, however the graphics and sound are good
Shorter than expected battery life
All in all, I'm very happy with this phone, and for only $50 after rebates on letstalk.com, it was hard to pass up. I do regret not buying a Windows Mobile format, but I wasn't sure how much time I'd have free for mobile programming at this point...so the Samsung t809 was the phone with all the features I'd wanted.