public string Upload() { try { int productId = 2; var product = _productRepository.GetProduct(productId); string fileSavingPath = XMLDownloader.GetFileName(productId); byte[] bytes = new byte[SchedulerConfig.MaxBytesCount]; // var file = Request.Files["file"]; using (System.IO.FileStream fs = System.IO.File.Create(fileSavingPath)) { int bytesRead; while ((bytesRead = Request.InputStream.Read(bytes, 0, bytes.Length)) > 0) { fs.Write(bytes, 0, bytesRead); } } _arrivalMessagesService.CreateArrivalMessage(product.Id, "", fileSavingPath, ""); var message = "success"; log.Info(message); return(message); } catch (Exception e) { var message = String.Format("{0}; {1}", e.Message, e.StackTrace); log.Error(message); return("error"); } }