1

I want to show word.docx to convert to pdf and show in my browser after docx document saved. But couldn't find any good source code, so decided to convert to HTML is simpler but when I send this HTML codes to View, I can see the HTML codes. The view doesn't rendering the HTML to show the outcome of the code.

VIEW = ConvertHTML.cshtml

 @model  string

CONTROLLER

public string ConvertHTML(string strDoc)
{
    var htmlCode = ParseDOCX(new FileInfo(strDoc));
    return h;
}

I tried this

public IActionResult ConvertHTML(string strDoc)
{
    var htmlCode = ParseDOCX(new FileInfo(strDoc));
    return View(h);
}

ERROR:

An unhandled exception occurred while processing the request. InvalidOperationException: The view ' xmlns="http://www.w3.org/1999/xhtml"> ..........

I also tried

@model  string
@Html.Raw(Model)

So far nothing is working

3
  • First of all it should be @Html.Raw(Model) Commented Apr 12, 2019 at 11:36
  • Your Docx to HTML is not correct. Follow this article Commented Apr 12, 2019 at 11:37
  • Thanks Adriani6 I typed wrong I already used @Html.Raw(Model) But still not working. It shows html code. Commented Apr 12, 2019 at 12:07

1 Answer 1

1

Change your code to:

public IActionResult ConvertHTML(string strDoc)
{
    var htmlCode = ParseDOCX(new FileInfo(strDoc));
    return Content(htmlCode, "text/html");
}
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect.Thank you for help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.