示例#1
0
        public async Task <ActionResult> Index(int seconds = 1)
        {
            try
            {
                var sent = await IoTHubHelper.SendDirectMethod(seconds);

                if (sent == 200)
                {
                    ViewBag.Result = "Message sent! ";
                }
                else
                {
                    ViewBag.Result = $"Error sending. {sent}";
                }
            }
            catch (IotHubException ex)
            {
                ViewBag.Result = $"Exception sending. {ex.Message}";
                Trace.TraceError(ex.Message);
            }
            return(View());
        }