Closed eduarmreyes closed 5 years ago
Do you use it form ASP.NET? It could be that library can't post to our rest api service. Check your permissions.
Do you use it form ASP.NET? It could be that library can't post to our rest api service. Check your permissions.
Yes, I am using it from ASP.NET, that is actually my guess, do you mind helping me understand where to check my permissions? 🤔
Do you run from the local pc?
Do you run from the local pc?
Yes, I do run from the local PC.
My workstation looks like this:
Created a new account not long ago, this is how my statistics look like.
This is how my code looks like.
[HttpPost]
// [ValidateAntiForgeryToken]
public ActionResult Index(string fromFormat, string toFormat, HttpPostedFileBase file)
{
if (fromFormat == "")
{
ViewBag.Message = "From format is required";
return View();
}
if (toFormat == "")
{
ViewBag.Message = "To format is required";
return View();
}
if (file == null || file.ContentLength <= 0)
{
ViewBag.Message = "File is required";
return View();
}
if (fromFormat == toFormat)
{
ViewBag.Message = "The 'from' and 'to' files types are the same.";
return View();
}
ConvertApi convertApi = new ConvertApi(Properties.Settings.Default.CONVERT_API_SECRET);
try
{
string path = Path.Combine(
Server.MapPath("~/Files"),
Path.GetFileName(file.FileName));
file.SaveAs(path);
var response = convertApi.ConvertAsync(fromFormat, toFormat,
new ConvertApiFileParam(@path)
);
ConvertApiResponse result = response.Result;
result.SaveFile(Server.MapPath("~/Files"));
}
catch (Exception ex)
{
ViewBag.Message = "ERROR: " + ex.Message.ToString();
}
return View();
}
The problem lies in Asynchronous handling in ASP.NET Web Forms. Please find the solution on how to use Async in ASP.NET at StackOverflow https://stackoverflow.com/a/56687401/281014
Hello, I have been having issues with the code examples to convert a file from docx to pdf using convertapi-dotnet.
The part where
ConvertApiResponse result = response.Result;
is executed never ends for a reason I don't fully understand.Any way somebody can help me with these?
I tried with VS 2019 .net v=4.7.2 and VS 2015 .net v=4.5.2 but don't seem to actually convert the file, though. 😩.