XML Parsing Error: no root element found Location in Console FF
I fixed this in my app by setting the Content-Type
header on the server to text/plain
. Like this in Node:
res.setHeader('Content-Type', 'text/plain');
Use whatever MIME type is appropriate for your data, ie application/json
, etc.
Check this link for more information
Based on my research, the error message is only generated by FireFox when the render page is blank in Internet. For some reason, .NET generates a response type of "application/xml" when it creates an empty page. Firefox parses the file as XML and finding no root element, spits out the error message.
in other words, this is a known Firefox issue
public IActionResult MethodName()
{
// YOUR CODE
return StatusCode(204);
}
Code 204 -The server successfully processed the request, and is not returning any content
For more details about status code check this page: List of HTTP status codes
I changed the type of return value in Action method and it worked. More details can be found in my article on this topic.
Changed from
return Ok();
to
return Json("Ok");