Wednesday, 23 July 2014

How to pass an array of integers to a asp.net web api rest service?

public IEnumerable GetCategories([ModelBinder(typeof(CommaDelimitedArrayModelBinder))]long[] categoryIds) 
{
// do your thing
}

public class CommaDelimitedArrayModelBinder : IModelBinder
{
    public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
    {
        var key = bindingContext.ModelName;
        var val = bindingContext.ValueProvider.GetValue(key);
        if (val != null)
        {
            var s = val.AttemptedValue;
            if (s != null)
            {
                var elementType = bindingContext.ModelType.GetElementType();
                var converter = TypeDescriptor.GetConverter(elementType);
                var values =
                    s.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries)
                     .Select(converter.ConvertFromString).ToArray();

                var typedValues = Array.CreateInstance(elementType, values.Length);

                values.CopyTo(typedValues, 0);

                bindingContext.Model = typedValues;
            }
            else
            {
                // change this line to null if you prefer nulls to empty arrays
                bindingContext.Model = Array.CreateInstance(bindingContext.ModelType.GetElementType(), 0);
            }
            return true;
        }
        return false;
    }
}


http://stackoverflow.com/a/19107738/1436831

How to build in release mode on TFS Build Server?

MongoDB Install as a Windows Service

Create a MongoDB config file as a filename like mongod.cfg logpath=c:\data\log\mongod.log dbpath=c:\data\db

In Cmd: sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB 2.6 Standard\mongod.cfg\"" DisplayName= "MongoDB 2.6 Standard" start= "auto"

Wednesday, 30 April 2014

TFS Service Authentication (TF30063)

http://ryanhanisco.com/tfs-service-authentication-tf30063/

Thursday, 10 April 2014

Windows ASP.NET : %1 is not a valid Win32 application Hatası

http://www.sekman.net/windows-asp-net-1-is-not-a-valid-win32-application-hatasi.html

Monday, 8 July 2013

Could not load file or assembly

http://blog.sql-assistance.com/index.php/could-not-load-file-or

Fixing the IE 8 warning

Going to Tools->Internet Options->Security Select the Security tab Click on the Internet zone icon at the top of the tab page Click the Custom Level button In the Miscellaneous section change Display mixed content to Enable Repeat steps 1 – 5 for the Local intranet and Trusted sites zones http://blog.httpwatch.com/2009/04/23/fixing-the-ie-8-warning-do-you-want-to-view-only-the-webpage-content-that-was-delivered-securely/