public ActionResult Download(string scoreId, string fileType, string fileName) { FoireMusesConnection connection = GetConnection(); Stream theStream; string contentType; switch (fileType) { case "pdf": contentType = "application/pdf"; break; case "mid": contentType = "audio/midi"; break; case "musicxml": contentType = "text/xml"; break; default: contentType = ""; break; } try { theStream = connection.GetConvertedScore(scoreId, fileName, new Result <Stream>()).Wait(); } catch (Exception e) { return(RedirectToAction("Problem", "Error", null)); } return(File(theStream, contentType, fileName)); }