My thoughts regarding ASP.NET, C#, programming practices, and more...
reading
You Should Read archives
blogs I read
|
Saturday, May 28, 2005Alternative to ApplicationPath
For some time now I have been fighting a battle that I thought I might never win. But once again the ASP.NET community comes through again with the following blog posting.
Problem I develop most of my websites locally on my Windows XP machine using it's native IIS. This means that I use relative paths. When creating user controls that I will be utilizing on pages throughout the site I may need to reference the Response.ApplicationPath property for an image tag or when calling Response.Redirect(). The code would look something like this: <img src="<%= Response.ApplicationPath %>/images/spacer.gif" /> This method works great until I push the website form my local machine to the staging server running Windows 2003. Suddenly anywhere I am using Response.ApplicationPath, I recieve a 404, "File Not Found" error. The reason being that while my website was hosted on my local machine, it lay in a sub-directory of one Default Website. However, on the staging server, it lies in the root directory of it's own website. This meant that on my local box a backslash was required after the Response.Application, but on the staging server, I had to remove the backslash. Solution Place the following code in the Application_BeginRequest event handler of the Global.asax file: // Build the Application Path This code should only run once and only if if the Application variable becomse null. Using the above code you should no longer have to worry about those moves from your local machine to staging or production web servers. Update 06/30/2005: See also Making Sense of ASP.Net Paths by Rick Strahl Friday, May 27, 2005Serializable
Problem
I was trying to add a custom collection of business entities/objects to the Session using the following code: Session["MatchingFiles"] = files; When I opened the aspx page that called the above code I received the following error message:
OK, no problem. I will just add [Serializable] to the top of both the custom collection and business object class declarations. After doing this, I refreshed the aspx page and received the same error message. Solution It took some doing, but I finally realized that both of these classes inherit from base classes. Neither of these base classes were marked serializable. Once I added [Serializable] to the base classes, the custom collection was able to be stored in Session state. Thursday, May 12, 2005What's New in C# 2.0
Yesterday evening I attended my first Arizona .NET User Group meeting. They offer several types of meetings every month. They include topics on ASP.NET, .NET Internals, SQL Server, and Smart Client. The meeting I attended yesterday was an .NET Internals session on "What's New in C# 2.0". Overall, I was very pleased with the presentation conducted by Joe Mayo. Joe is the author of C# Unleashed, and C# Builder Kick Start. He is also an instructor and owner of Mayo Software Training.
He went over the following: 1. Generics 2. Iterators 3. Anonymous Methods 4. Partial Types (i.e. partial classes) 5. Nullable Types 6. Misc a. Static classes only need to be declared with the 'static' keyword. b. Namespace Alias Qualifiers. c. External Alias d. Coalesce Operator (??) I will try and make time to post in detail some of the new things I have learned. Stay tuned. Wednesday, May 11, 2005Two Critical Security Holes Found in FireFox
For those of you who surf with Mozilla's FireFox browser, make sure you upgrade to FireFox version 1.0.3.
Apparantly there have been two "potentially critical" security holes found in FireFox. Here is an excerpt from Security Advisory on Mozilla.org: "Security Advisory (May 8, 2005) The Mozilla Foundation is aware of two For information, check out the article Two Critical and Unpatched Flaws Found In Firefox Browser on All Headline News. I was using FireFox for a short time, but I am now using Maxthon. Friday, May 06, 2005OFF TOPIC: Free Sony PSP
I usually believe these things are malarky, but I was reading Luke Hutterman's blog (the creator of SharpReader) and saw that he used the same service to get a free Mini Mac for himself.
The way it works is this, you click on the this link, sign up, complete one of the offers, and then get 5 other people to do the same. Seems pretty straight forward. Luke had to get 10 other people to do the same in order to get the Mini Mac. So, if you would like to help me get a free Sony PSP and maybe get one for yourself go here. Tuesday, May 03, 2005Google Desktop = Life Saver
When you get a moment, I would highly recommend installing Larry's Any Text File Indexer, a free plug-in.
Content copyright ©2003-2006 Tod Birdsall
You can search for keywords in specific files using the "filetype:" keyword in your search. Example: filetype:cs PageLoad As a side note...has anyone taken the time to research how resource intensive this app is? I barely notice it is there. I am wondering how much space is taken up by all of this caching. |