public async Task<ActionResult> Import(ImportViewModel viewModel) { if (!ModelState.IsValid) return View(viewModel); XDocument document; try { document = XDocument.Load(viewModel.UploadFile.InputStream); } catch (Exception) { ModelState.AddModelError("UploadFile", "Received invalid XML."); return View(viewModel); } var userId = GetUserId(); await Task.Run(() => new TelemetryClient().TrackEvent("ImportFilters")); //Use MongoDb to temporarily store instead of the session. var mongoDbComponent = new MongoDbComponent(); var collection = mongoDbComponent.MessageFilters; var filterComponent = new MessageFilterComponent(); var id = await collection.InsertAsync(filterComponent.FromXml(document, userId)); return RedirectToAction("ImportReview", new { id = id }); }