Go to home page mail me! RSS Feed
FoxMetrics Web Analytics

.Net Framework 3.5

Running IIS 7 in 32-bit mode

Its all nice and good when you are running all your websites in 64-bit, however, there are times when you need to run certain websites in 32bit – such as when you have a third party library that just doesn’t play nice in 64-bit. There are several workarounds - well, you can start by re-installing your OS in 32-bit, you could run the website in a 32-bit mode virtual machine, however, my favorite is to run IIS in 32-bit mode and here is how you do it. IIS PowerShell Provider set-itemproperty iis:\ -name applicationPoolDefaults.enable32BitAppOnWin64 -value true Command...

posted @ Wednesday, February 02, 2011 3:02 PM | Feedback (0)

Get a list of all time zones

The following loop will give you access to a list of all time zones on the local system machine. foreach (TimeZoneInfo tzi in TimeZoneInfo.GetSystemTimeZones()) { // Do stuff with tzi here }

posted @ Sunday, October 17, 2010 12:38 PM | Feedback (0)

Get week number from date

Here is a simple way to get the week number given a certain date and time. int week = System.Globalization.CultureInfo.CurrentCulture.Calendar.GetWeekOfYear( dt, System.Globalization.CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday);

posted @ Monday, April 05, 2010 12:00 AM | Feedback (0)

TryParse on nullable types

For some unknown reason you can’t do a TryParse on nullable types or should I say the out parameter of a TryParse can not be nullable? For example this just won’t work. DateTime? dt; DateTime.TryParse("12/12/2010", out dt); Error 4 The best overloaded method match for 'System.DateTime.TryParse(string, out System.DateTime)' has some invalid arguments The solution or workaround is to use two variables to accomplish the goal, here is an example. DateTime? dt1; DateTime dt2; dt1 = DateTime.TryParse("12/12/2010", out dt2) ? dt2 : (DateTime?)null;

posted @ Saturday, March 13, 2010 3:37 PM | Feedback (0)

Taking my key value store to another level

Before I start cramming code, I’ll like to know what you guys think. I’ve been working heavily on my key value store and it has been working as expected, however, the main reason for me building this store does not seem to be completely eliminated with the functionalities that I have in place so far. therefore, I’ll like to add an extra piece to the jigsaw but before I do so I’ll like to hear what you have to say. The storage engine itself is solid and it works with the minimal functionalities that it currently has. As a...

posted @ Saturday, March 06, 2010 8:40 PM | Feedback (0)

Adding “class” attribute to htmlAttributes of the HtmlHelper in MVC

I’ve seen lots of questions on how you can add a “class” attribute to any html tag such as the “a” tag while using the HtmlHelper class in ASP.NET MVC. The problem here is “class” is a reserved keyword in .NET so you just can’t use “class” in the htmlAttributes object of the HtmlHelper class. i.e. this will work perfectly. <%=Html.ActionLink("Log in","Login", null, new { id = "idforthislink" } %> but this won’t <%=Html.ActionLink("Log in","Login", null, new { id = "idforthislink", class ="red" } %> It will error out on class. Here is the proper way of doing it. <%=Html.ActionLink("Log in","Login", null, new...

posted @ Friday, November 27, 2009 1:22 PM | Feedback (0)

A simple way to resize an image

Here is a very simple way to resize an image using a bitmap as a canvas and the graphics object as a the resizing tool. Don’t forget to reference System.Drawing. /// <summary> /// Resizes an image from a source file to a destination file /// the destination file will contain the exact image at the size specified /// </summary> /// <param name="sourceImagePath">the source image file that needs to be resized</param> /// <param name="destinationImagePath">the destination path that the source /// image file needs to be resized to</param> /// <param name="width">the new width</param> /// <param name="height">the new height</param> static void ResizeImage(string sourceImagePath, ...

posted @ Tuesday, July 28, 2009 10:13 AM | Feedback (20)

Write out page load times using an HttpModule and the stopwatch class

One of the most efficient and non-intrusive ways you can implement an intercepting procedure is via an HttpModule. An HttpModule simply receives every request going to or coming from IIS and it allows you to manipulate the content as you see fit and pass it along. I wanted to spit out the time it takes from receiving a request to writing the response on one or more web pages and there was no other better way of doing it except writing an HttpModule, it toke me all but 10mins. Here is the code, feel free to blow it up. ...

posted @ Friday, July 24, 2009 1:40 PM | Feedback (0)

Get underlying type from a nullable type

As my forever quest for simple & reusable code keeps growing, I stumble across some bottlenecks once in a while. Anyway, I have a simple class that is called "PopulateObjectFromFormRequest" and as descriptive as the name is, it does one simple yet helpful task. Given an object as a generic type I.e (user) and a web form as a parameter I.e (aspnetform), it will scan through all the controls of that web form and use reflection on the object and assign values to the object properties that matches controls from within the form. How does this help me? Well if I my...

posted @ Tuesday, March 11, 2008 11:33 AM | Feedback (5)

MVC for Visual Studio Express 2008

For those of us who can't always afford to buy the ridiculously expensive VS Pro/Team 2008 - shouldn't Microsoft be giving those out for FREE. After all we are only promoting windows, without us developers the Windows operating system will be more or less like TinyOS. Anyway, lets leave that for another day. I like using express simply because its lightweight and I don't really use all the features of the Pro versions anyway, I only wish I could "attach to process" then the express editions would be 100% ideal for me. Any who, the express editions do not support MVC - actually...

posted @ Thursday, February 07, 2008 2:03 PM | Feedback (0)

Full .Net Framework 3.5 Archive

Next entries »