public ActionResult Information(DeviceRegistration registration) { if (ModelState.IsValid) { using (AzureManagerContext context = new AzureManagerContext()) { DeviceRegistration deviceRegistration = context.DeviceRegistrations.Find(registration.Id); if (HttpContext.Request.Files.Count > 0) { using (BinaryReader r = new BinaryReader(HttpContext.Request.Files[0].InputStream)) { byte[] buffer = new byte[HttpContext.Request.ContentLength]; r.Read(buffer, 0, HttpContext.Request.ContentLength); deviceRegistration.Certificate = buffer; } } deviceRegistration.SubscriptionId = registration.SubscriptionId; context.SaveChanges(); RegistrationModel model = new RegistrationModel(); String response = model.NotifyDeviceOfInformation(deviceRegistration); ViewBag.Response = response; } return RedirectToAction("InformationSent"); } return View(registration); }