Wednesday, September 4, 2013

Deploy ASP MVC on IIS 6

This post just complements information already available online.
There are certain steps you need to do first before your ASP MVC application can run in IIS 6.

In the Properties screen, on the Directory tab click Configuration.


On the Mappings tab, click Insert to insert a wildcard application map:


Browse to the location of the aspnet_isapi.dll file. Make sure that Verify that file exists check-box is clear.

Click OK to save your changes. That should be enough provided you have all the required dll files in the bin folder.

Thursday, July 18, 2013

Copy Property Values

If you have 2 objects that do not inherit from each other but have similar properties, here is a function you can use to copy property values from one object to the other:

    public static void CopyIdenticalProperties (this object source, object dest)
        {
            var plist = from prop in source.GetType().GetProperties()
                        where prop.CanRead && prop.CanWrite
                        select prop;

            foreach (PropertyInfo prop in plist)
            {
                var destProp = dest.GetType().GetProperty(prop.Name);              
                if (destProp != null)
                {
                    destProp.SetValue(dest, prop.GetValue(source, null), null);
                }
            }
        }

Wednesday, June 12, 2013

Format Phone Number

This is how you could format a phone number using a period as a separator:

String.Format("{0:###\\.###\\.####}", 1234567890);

The resulting string will look as follows: 123.456.7890.