What could be causing an XML Parsing Error: no element found?

前端 未结 15 1840
刺人心
刺人心 2020-12-20 11:49

I recently migrated an ASP site from my dev machine to a live server. All the pages except my FAQ page works just fine, but my FAQ brings up:

XML Parsing Er         


        
相关标签:
15条回答
  • 2020-12-20 12:44

    I ran in to this and found at least for me it was because in C# WebAPI 2 if you return an empty Ok() result that it returns XML as content type. Even if you override it in the WebAPI config to not return XML ever. So my solution was to make this function in a Base Controller class I have and use it anywhere I need to return an empty OK() JSON response. One could make it more advanced for their needs but this is what I did. I guess you could maybe use an AttributeFilter as well maybe but I did this solution as it is same amount of code in Action.

    protected IHttpActionResult OKJSONResult()
    {
        HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "", new MediaTypeHeaderValue("application/json"));
        return ResponseMessage(response);
    }
    
    0 讨论(0)
  • 2020-12-20 12:46

    no xml declaration in the beginning

    <?xml version="1.0"?>

    0 讨论(0)
  • 2020-12-20 12:48

    I don't know anything about ASP.NET, but from my generic experience with web frameworks, it sounds like your application failed to produce any output at all. Usually that means that there was an exception before any output rendering took place, so try looking through the logs to find out what caused it...

    0 讨论(0)
提交回复
热议问题