public void ProcessRequest(HttpContext context) { string result = "Nothing was done."; try { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Cart)); Cart cart = (Cart)serializer.ReadObject(context.Request.InputStream); result = CartItems.SendOrder(cart.Items, cart.User, cart.Notes, cart.OrderNumber); } catch (Exception exception) { result = exception.Message; } finally { using (StreamWriter writer = new StreamWriter(context.Response.OutputStream)) { writer.Write(result); } } }