Thứ Hai, 28 tháng 11, 2016

Route Constraints

https://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2#constraints
ConstraintDescriptionExample
alphaMatches uppercase or lowercase Latin alphabet characters (a-z, A-Z){x:alpha}
boolMatches a Boolean value.{x:bool}
datetimeMatches a DateTime value.{x:datetime}
decimalMatches a decimal value.{x:decimal}
doubleMatches a 64-bit floating-point value.{x:double}
floatMatches a 32-bit floating-point value.{x:float}
guidMatches a GUID value.{x:guid}
intMatches a 32-bit integer value.{x:int}
lengthMatches a string with the specified length or within a specified range of lengths.{x:length(6)}
{x:length(1,20)}
longMatches a 64-bit integer value.{x:long}
maxMatches an integer with a maximum value.{x:max(10)}
maxlengthMatches a string with a maximum length.{x:maxlength(10)}
minMatches an integer with a minimum value.{x:min(10)}
minlengthMatches a string with a minimum length.{x:minlength(10)}
rangeMatches an integer within a range of values.{x:range(10,50)}
regexMatches a regular expression.{x:regex(^\d{3}-\d{3}-\d{4}$)}

Chủ Nhật, 27 tháng 11, 2016

Thứ Bảy, 19 tháng 11, 2016

Enabling Windows Authentication in Katana

https://www.asp.net/aspnet/overview/owin-and-katana/enabling-windows-authentication-in-katana

using System.Net;

namespace Owin
{
    public static class WindowsAuthenticationExtensions
    {
        public static IAppBuilder UseWindowsAuthentication(this IAppBuilder app)
        {
            object value;
            if (app.Properties.TryGetValue("System.Net.HttpListener", out value))
            {
                var listener = value as HttpListener;
                if (listener != null)
                {
                    listener.AuthenticationSchemes =
                        AuthenticationSchemes.IntegratedWindowsAuthentication;
                }
            }

            return app;
        }
    }
}

Thứ Tư, 16 tháng 11, 2016

Regex pattern for comma separated list

<textarea ng-pattern="/^([^,]+)(,[^,]+)*$/i"></textarea>

Allow one comma at the end:

<textarea ng-pattern="/^([^,]+)(,[^,]+)*(,?)$/i"></textarea>

Thứ Sáu, 4 tháng 11, 2016

Configure TortoiseSVN to use Visual Studio 2015 for Diff Viewer

Settings -> Diff Viewer -> External -> paste the command as below:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe -diff %base %mine

or

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsDiffMerge.exe /t %base %mine %bname %yname