Tuesday, November 22, 2005 9:19:57 PM UTC :: Filed Under ASP.NET

Have you ever found it annoying that any time you download some sample code you had to configure a virtual directory in IIS just to see it work, only to delete it if it wasn’t of use to you?  Well, with the .NET 2.0 Framework and a little help from Robert McLaws, you can now browse web sites from anywhere using the new built-in web server feature of ASP.NET 2.0:

"ASP.NET 2.0 Web Server Here" Shell Extension

In the above blog post, Robert had a few issues with his solution which he apparently resolved with the .msi which can be downloaded here.

The coolest part is that it even works on ASP.NET 1.1 projects! w00t!

Tuesday, November 22, 2005 9:04:04 PM UTC :: Filed Under ASP.NET

I’m going to have to make reading Scott Guthrie’s blog part of my daily ritual because nearly every post is packed with useful information!  This article shows how to run a web application on your development PC as though it was running at the top-level (or “root”) web site, even if it’s configured to run in a virtual root:

How to Run a Root “/” Site with the VS/VWD 2005 Local Web Server

Why is this cool?  If you haven’t already figured it out, here’s my lame explanation:

When you configure a web site on a Windows 2003 Server using IIS 6, each site has its own root directory because IIS 6 on a web server allows for the creation of multiple web sites.  However, on a development machine running Windows XP Pro and IIS 5, you can only have one web site defined which means all other sites must be contained in virtual root folders below the main site.   The problem that this creates is that it becomes difficult to reference file paths to static files and folders.

For example, if your site contains an “images” folder and a “templates” folder (which contains your .ASCX user controls), you will likely want to reference images from within one of your user controls.  On a web server, you could reference an image path like this:

<img src=”/images/someimage.gif” alt="My Alt Tag" />

However, that won’t work on a development PC running IIS 5 with a site defined as a virtual root.  The path would then have to be:

<img src=”/myvirtualroot/images/someimage.gif” alt="My Alt Tag" />

Starting to see the problem here?  In the second example, all your images will break when you copy your files from your development PC to the live web server.   Using the “../” method to navigate to images used to work:

<img src=”../images/someimage.gif” alt="My Alt Tag" />

However, do to naughty people trying to run scripts through the address bar in the browser, IIS often won’t allow for the “../” notation.  One solution is to use the method ResolveURL along with the “~/” prefix:

<img src="<%# Control.ResolveUrl(“~/images/someimage.gif”) %>" alt="My Alt Tag" />

But that’s just plain ugly code!   Utilizing Scott’s trick, you can reference your file paths as though you were working on a live web server without having to do any ugly work-around. Schweet!

Tuesday, November 22, 2005 7:37:43 PM UTC :: Filed Under ASP.NET | VB.NET

The .NET 2.0 Framework supports a new string method for VB that should prove to be useful:

returnValue = String.IsNullOrEmpty(value)

IsNullOrEmpty is a convenience method that enables you to simultaneously test whether a String is a null reference (Nothing in Visual Basic) or its value is Empty.

 

Tuesday, November 22, 2005 6:55:28 PM UTC :: Filed Under ASP.NET

Note that if you are trying to configure Profiles in ASP.NET 2.0, there no longer is a ‘Profile’ tab in the ASP.NET Web Site Administration Tool.  This tab appears in the Beta 1 and found it’s way into a lot of documentation and web casts, but was apparently removed in Beta 2 and the final release.  As a result, if you want to configure custom Profile Properties or use a custom Profile Provider, you must do so manually in the web.config file.

Monday, November 21, 2005 10:21:18 PM UTC :: Filed Under ASP.NET | SQL | VB.NET

When writing SQL statements, it's a good practice to always use "AS" after calling each field. This will allow for column name changes that won't break your code.  For example, the following is a simple SELECT statement:

SELECT Id AS UserId, FirstName AS FirstName, LastName AS LastName FROM Users

If some of the column names change, such as the FirstName and LastName columns, my code won't break:

SELECT Id AS UserId, FirstName AS NameFirst, NameLast AS LastName FROM Users

Thanks to Jelle Druyts for this useful tip.

Friday, November 11, 2005 9:12:22 PM UTC :: Filed Under ASP.NET | VB.NET

Who says that developers are boring and weird?  Well, they are weird, but sometimes they can be fun:

VSTSRap_small1.jpg

http://www.microsoft.com/korea/events/ready2005/vs_song.asp

I’m not sure if I think the video is funny because of the content or because of the Korean language that I don’t understand!

The lyrics are very good too when translated into English... they seem to relate to my job pretty well!

Navigation
On this page....
Search
Archives
<November 2005>
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910
Categories
Contact me
Send mail to the author(s) Contact Todd M. Taylor