protected void registerBtn_Click(object sender, EventArgs e) { string fullName = txt_new_fullName.Text; string pilgrimId = txt_new_pilgrimId.Text; string userId = txt_new_userId.Text; string nationality = txt_new_nationality.Text; string residency = txt_new_residency.Text; double credit = Convert.ToDouble(txt_new_credit.Text); string phone = txt_new_phone.Text; Bitmap fpImage = new Bitmap(fingerPrint.PostedFile.InputStream); byte[] data; using (MemoryStream stream = new MemoryStream()) { fpImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png); data = stream.ToArray(); } // test //BsonDocument pilgrim = operations.findPilgrim(pilgrimId); if (operations.findPilgrim(pilgrimId) == null) { Pilgrim newP = new Pilgrim(fullName, pilgrimId, userId, nationality, residency, data, credit, phone); operations.createNewPilgrimAccount(newP.getBsonDoc()); } else { // the id already exists } }