Ejemplo n.º 1
0
        public ActionResult Index(UrlModell url)
        {
            if (ModelState.IsValid)
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(_ApiUrl);
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


                    string result = client.PostAsync("/short",
                                                     url.LongURL,
                                                     new JsonMediaTypeFormatter())
                                    .Result
                                    .Content
                                    .ReadAsAsync <string>()
                                    .Result;


                    url.ShortURL = result;
                    //ViewData["ShortURL"] = result;
                    return(View(url));
                }
                //return View();
            }
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            UrlModell url = new UrlModell();

            return(View(url));
        }