Пример #1
0
        /// <summary>
        /// Decodes the  encrypted URL.
        /// </summary>
        /// <param name="key">encrpted URL.</param>
        /// <returns>User friendly URL.</returns>
        public string DecodeUrl(string key)
        {
            ShortUrlProvider provider   = new ShortUrlProvider();
            string           decodedUrl = provider.DecodeUrl(key);

            return(decodedUrl);
        }
 /// <summary>
 /// Encodes the provided url by mixing with random character.
 /// </summary>
 /// <param name="url">User friendly URL.</param>
 /// <returns>Encoded URL.</returns>
 public string EncodeUrl(string url)
 {
     string shortUrlkey = string.Empty;
     string code = string.Empty;
     ShortUrlProvider provider = new ShortUrlProvider();
     while (true)
     {
         string randomText = GenerateRandomCode();
         string random = GetRandomText(randomText);
         code = provider.EncodeUrl(url, random);
         if (code != "-1")
             break;
     }
     string encodedUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath + "/suid/" + code;
     return encodedUrl;
 }
Пример #3
0
        /// <summary>
        /// Encodes the provided url by mixing with random character.
        /// </summary>
        /// <param name="url">User friendly URL.</param>
        /// <returns>Encoded URL.</returns>
        public string EncodeUrl(string url)
        {
            string           shortUrlkey = string.Empty;
            string           code        = string.Empty;
            ShortUrlProvider provider    = new ShortUrlProvider();

            while (true)
            {
                string randomText = GenerateRandomCode();
                string random     = GetRandomText(randomText);
                code = provider.EncodeUrl(url, random);
                if (code != "-1")
                {
                    break;
                }
            }
            string encodedUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath + "/suid/" + code;

            return(encodedUrl);
        }
 /// <summary>
 /// Decodes the  encrypted URL.
 /// </summary>
 /// <param name="key">encrpted URL.</param>
 /// <returns>User friendly URL.</returns>
 public string DecodeUrl(string key)
 {
     ShortUrlProvider provider = new ShortUrlProvider();
     string decodedUrl = provider.DecodeUrl(key);
     return decodedUrl;
 }