Пример #1
0
        public JsonResult GetShortJson(string oldUrl)
        {
            AjaxRespone ar = new AjaxRespone();

            try
            {
                if (string.IsNullOrEmpty(oldUrl))
                {
                    throw new Exception("请输入原始链接");
                }
                var url = ShortUrlService.DataBaseShortUrl(oldUrl);
                if (string.IsNullOrEmpty(url))
                {
                    throw new Exception("短链接转换为失败");
                }
                ar.ErrorCode = 0;
                ar.Result    = link + url;
            }
            catch (Exception ex)
            {
                ar.ErrorCode = 1;
                ar.ErrorDesc = ex.Message;
            }
            return(Json(ar));
        }
Пример #2
0
        public JsonResult GetLongJson(string newUrl)
        {
            AjaxRespone ar = new AjaxRespone();

            try
            {
                if (string.IsNullOrEmpty(newUrl))
                {
                    throw new Exception("请输入短链接");
                }
                var url = ShortUrlService.GetLongUrl(newUrl);
                ar.ErrorCode = 0;
                ar.Result    = url;
            }
            catch (Exception ex)
            {
                ar.ErrorCode = 1;
                ar.ErrorDesc = ex.Message;
            }
            return(Json(ar));
        }