As the subject states, I quickly set up a MVC4 web application in Visual Studio 2012. All I wanted was to perform a quick test of inserting HTML to an existing Word (docx) template and send the result to a client browser (IE11 in my case).
Below is my controller in its entirety:
using System.Web;
using System.Web.Mvc;
using Aspose.Words;
namespace MvcAspose.Controllers
{
public class HelloWorldController : Controller
{
public ActionResult Index()
{
return View();
}
public void AsposeTest()
{
Document doc = new Document(@“C:\Temp\WordTemplate.docs”);
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(“
Hello World!
”);
doc.Save(System.Web.HttpContext.Current.Response, “DocumentBuilder.InsertHtml AsposeOut.docx”,
ContentDisposition.Inline,
null);
}
}
}
And when I invoke the ‘AsposeTest’ method, I get a runtime error that says, “Input string was not in a correct format.” which points to the ‘doc.Save(…)’ call. Is there any obvious mistake that I’m not seeing?