December 2008 Entries

IIS Set Expiration Dates adds the expiration header only to static content

12 Steps To Faster Web Pages With Visual Round Trip Analyzer recommends (among others useful suggestions) to Set Expiration Dates - follow Using Content Expiration (IIS 6.0), . I've looked in a few articles, including Best Practices for Speeding Up Your Web Site, "Optimizing a Page-Load Performance Profile and Optimization of a Web Site - Using Content Expiration (IIS 6.0) . Finally the post IIS Content expiration header and ASP.NET cleared my concerns: IIS is smart enough to add the expiration header ......

Helper functions to find pattern contaned in string from pattern List

Below are a few helper functions for List<string> generic class. They could be modified to be extension methods. //See also StringArrayHelper.cs, CollectionsHelper.cs public static class ListOfStringsHelper { public static bool StringContainsAnyFromList(L... patternsList, string sMsg) { bool bFound = patternsList.Exists( delegate(string pattern) { return sMsg.Contains(pattern); } ); return bFound; } public static string FindFirstListItemContainedI... patternsList, ......

ToString function for Generic List

Below is the method to output Generic list of objects as string. UPDATE: I've replaced my original function with the code suggested by James Curran (see his comment below). public static string ToString<T>(IEnumerab... messages, string sComment) { StringBuilder sRet = new StringBuilder(sComment); if (messages != null) { foreach (T msg in messages) { sRet.AppendLine(msg.ToStrin... } } return sRet.ToString(); } /// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> ......

Access to Relative To Application Root File

Sometimes you have a file relative to the root of application, that you want to read from your code. However when your code is build on development machine, the binary files are located in "\bin\debug","\bin\release" or just "\bin"(for VB or Web projects). And you need to make copy of files relative to bin/debug folder. The function below helps to find the file, even if it was not copied to bin subfolder. (Should I name it ResolvePath smilar to Page.ResolveUrl?) Note, that in most cases Visual Studio ......

Debugging Windows Services with "Edit & Continue"

I needed to debug Windows Services. But I didn't like suggested in multiple articles Debugger.Launch. Thanks to post "Debugging Windows Services is a Pain" (and article CodeProject: Debugging Windows Services under Visual Studio .NET) I was able 1. To download Service Debugging Helper (Binary) (or Service Debugging Helper (Binary + Source)) 2. Add in my service project a Reference to AndersonImes.ServiceProcess... 3. Change in the Main() function //ServiceBase.Run(ServicesT... ServicesLoader.StartService... ......

Understand Project dependency Hierarchy in VS solution

I have a huge VS solution(with more than 60 projects) and for some projects order of references is not obvious. If you do not understand the hierarchy,you will get circular dependency":Adding this project as a reference would cause a circular dependency." Unfortunately, Visual Studio doesn't create diagram to show projects hierarchy. Open Source Project dependency graph generator didn't help me, because it created only 2 levels of hierarchy for my huge solution. Also for project with . in the name(e.g. ......

Avoid throwing exception from asynchronous delegate.

I am using delegate to invoke asyncronous call of the function. Sometimes the function can throw exception. As described in thread Re: exception handling with events , article "Handling Exceptions Thrown from an Asynchronous Delegate"(and in many other places) "You should call EndInvoke in a try/catch block to catch any exceptions your asynchronous method threw". I followed the same approach in my Asynchronous long-running tasks in ASP.NET application The code is like the following: RecalculateDelegate ......

Helper functions to get last element in collection

Below are couple simple helper functions to get last element in collection: public static Object LastElement(Object[] myArr) { if( IsNullOrEmpty(myArr)) { return null; } return myArr[myArr.Length-1]; } public static DataRow GetLastRow(DataTable tbl) { if (tbl == null) { throw new NullReferenceException("tbl is null"); } if (tbl.Rows.Count == 0) { return null; } return tbl.Rows[tbl.Rows.Count - 1]; } ......

«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910