Example #1
0
 private string ReadFrom(Stream bodyStream)
 {
     try
     {
         using (var bodyReader = new HttpRequestStreamReader(bodyStream, Encoding.UTF8))
         {
             return(bodyReader.ReadToEnd());
         }
     }
     catch (Exception ex) when(ex is IOException ||
                               ex is OutOfMemoryException ||
                               ex is ArgumentOutOfRangeException ||
                               ex is ObjectDisposedException)
     {
         return(string.Empty);
     }
 }
Example #2
0
        public ActionResult <ResolvedURL> Submit()
        {
            using (var streamReader = new HttpRequestStreamReader(Request.Body, System.Text.Encoding.UTF8))
            {
                // deserialize JSON
                URLContainer urlObj    = JsonConvert.DeserializeObject <URLContainer>(streamReader.ReadToEnd());
                ResolvedURL  randomUrl = LinkGenerator.AddURL(urlObj.url);

                return(randomUrl);
            }
        }