public ActionResult Sample23() { // Check is data posted if (Request.HttpMethod == "POST") { //### Set variables and get POST data System.Collections.Hashtable result = new System.Collections.Hashtable(); String clientId = Request.Form["clientId"]; String privateKey = Request.Form["privateKey"]; String fileId = Request.Form["fileId"]; String url = Request.Form["url"]; var file = Request.Files["file"]; String guid = ""; String basePath = Request.Form["basePath"]; // Set entered data to the results list result.Add("clientId", clientId); result.Add("privateKey", privateKey); result.Add("basePath", basePath); String message = null; String iframe = ""; // Check is all needed fields are entered if (clientId == null || privateKey == null) { // If not all fields entered send error message message = "Please enter all parameters"; result.Add("error", message); return View("Sample23", null, result); } else { if (basePath.Equals("")) { basePath = "https://api.groupdocs.com/v2.0"; } // Create service for Groupdocs account GroupdocsService service = new GroupdocsService(basePath, clientId, privateKey); //if URL to web file was provided - upload the file from Web and get it's GUID if (!url.Equals("")) { //Make request to upload file from entered Url String uploadWeb = service.UploadUrl(url); if (uploadWeb != null) { //If file uploaded return his GuId guid = uploadWeb; } //If file wasn't uploaded return error else { result.Add("error", "Something wrong with entered data"); return View("Sample23", null, result); } } //if file was uploaded locally - upload the file and get it's GUID if (!file.FileName.Equals("")) { //Upload local file Groupdocs.Api.Contract.UploadRequestResult upload = service.UploadFile(file.FileName, String.Empty, file.InputStream); if (upload.Guid != null) { //If file uploaded return his guid guid = upload.Guid; } else { //If file wasn't uploaded return error result.Add("error", "Something wrong with entered data"); return View("Sample23", null, result); } } if (!fileId.Equals("")) { guid = fileId; } //Make request to get document pages as images Groupdocs.Api.Contract.ViewDocumentResult pageImage = service.ViewDocument(guid, 0, null, null, 100, false); if (pageImage.Guid != null) { // Generate Embed viewer url with entered file id if (basePath.Equals("https://api.groupdocs.com/v2.0")) { iframe = "https://apps.groupdocs.com/document-viewer/embed/" + pageImage.Guid; } if (basePath.Equals("https://dev-api-groupdocs.dynabic.com/v2.0")) { iframe = "https://dev-apps-groupdocs.dynabic.com/document-viewer/embed/" + pageImage.Guid; } if (basePath.Equals("https://stage-api-groupdocs.dynabic.com/v2.0")) { iframe = "https://stage-api-groupdocs.dynabic.com/document-viewer/embed/" + pageImage.Guid; } if (basePath.Equals("https://realtime-api.groupdocs.com/v2.0")) { iframe = "https://realtime-apps.groupdocs.com/document-viewer/embed/" + pageImage.Guid; } iframe = Groupdocs.Security.UrlSignature.Sign(iframe, privateKey); result.Add("iframe", iframe); //Return page images GuId to the template result.Add("fileId", pageImage.Guid); return View("Sample23", null, result); } //If request return empty GuId set error for template else { result.Add("error", "Something wrong with entered data"); return View("Sample23", null, result); } } } // If data not posted return to template for filling of necessary fields else { return View("Sample23"); } }