public dynamic Get([FromQuery] string id) { var personEntity = App.Query["PersonUrlKey"].List.FirstOrDefault(); if (personEntity == null) { throw new Exception("Can't find person with id " + id); } var person = AsDynamic(personEntity); var card = new VCard { FirstName = person.FirstName, LastName = person.LastName, Organization = Settings.CompanyName, JobTitle = person.Function, StreetAddress = person.Street, Zip = person.ZipCode, City = person.City, CountryName = person.Country, Phone = person.Phone, PhoneCompany = Settings.CompanyPhone, // Mobile = person.,// queryString["mobile"], Email = person.EMail, Url = Settings.CompanyUrl, }; if (Text.Has(person.Image)) { var photoPath = Link.Image(person.Image, width: 250, height: 250, quality: 80, format: "jpg", type: "full"); card.PhotoBase64 = CreateThumbnail(photoPath); } var mimeType = "text/vcard"; var fileName = card.FirstName + " " + card.LastName; if (string.IsNullOrWhiteSpace(fileName)) { fileName = card.Organization; } if (string.IsNullOrWhiteSpace(fileName)) { fileName = "contact"; } fileName += ".vcf"; var cardString = card.ToString(); var inputEncoding = Encoding.Default; var outputEncoding = Encoding.GetEncoding(28591); // ISO-8859-1 var cardBytes = inputEncoding.GetBytes(cardString); var outputBytes = Encoding.Convert(inputEncoding, outputEncoding, cardBytes); return(File(download: true, contents: outputBytes, contentType: mimeType, fileDownloadName: Path.GetFileName(fileName))); }