Microsoft.Web.Administration.VirtualDirectoryPathValidator.Validate C# (CSharp) Method

Validate() public method

public Validate ( object value ) : void
value object
return void
        public override void Validate(object value)
        {
            var data = (string)value;
            if (string.IsNullOrWhiteSpace(data))
            {
                throw new COMException("Invalid virtual directory path\r\n");
            }

            if (data[0] != '/')
            {
                throw new COMException("Invalid virtual directory path\r\n");
            }

            if (data.Length > 1 && data[data.Length - 1] == '/')
            {
                throw new COMException("Invalid virtual directory path\r\n");
            }

            var items = data.Split('/');
            foreach (var item in items)
            {
                if (item == "." || item == "..")
                {
                    throw new COMException("Invalid virtual directory path\r\n");
                }
            }
        }
    }
VirtualDirectoryPathValidator