public async Task <JsonResult> Index(string stringToProcess) { //stringToProcess = "Hello"; string HardCodeString = @"<InputDocument> <DeclarationList> <Declaration Command='DEFAULT' Version='5.13'> <DeclarationHeader> <Jurisdiction>IE</Jurisdiction> <CWProcedure>IMPORT</CWProcedure> <DeclarationDestination>CUSTOMSWAREIE</DeclarationDestination> <DocumentRef>71Q0019681</DocumentRef> <SiteID>DUB</SiteID> <AccountCode>G0779837</AccountCode> </DeclarationHeader> </Declaration> </DeclarationList> </InputDocument> " ; XmlDocument doc = new XmlDocument(); doc.LoadXml(HardCodeString); try { doc.LoadXml(string.IsNullOrEmpty(stringToProcess) ? HardCodeString : stringToProcess); var result = ProcessFile.ProcessFileXml(doc); string message = string.Empty; switch (result) { case 0: message = "The document was structured correctly"; break; case -1: message = "Invalid command specified"; break; case -2: message = "Invalid Site specified"; break; default: break; } return(new JsonResult(new { StatusCode = result, Message = message })); } catch (XmlException ex) { return(new JsonResult(ex.ToString())); } }