Asked by:
Response Content-Type is returned as text/html instead of application/json

Question
-
Overview of my application -> Web UI built on MVC .NET 4.5 and its calling a backend Web API .NET 4.5 REST service to get data.
When my web application loads for the first time, it throws an Internal Server Error. If I refresh the page, it works fine.
On checking my Chrome Tools Network log, i saw that the content-type is returned as text/html instead of application/json. That is the only difference which I saw in both the request/responses captured.
Can anyone please let me know how can I triage and fix this issue ?
- Moved by Wendy ZangMicrosoft contingent staff Monday, November 13, 2017 8:55 AM
Saturday, November 11, 2017 5:14 PM
All replies
-
Either the client needs to expect a context-type of HTML. I would say that the first response is a HTTP 200 OK or some HTTP response code, and then the Json is or is not sent based on the HTTP response code.
Anyway, your issues can be addressed at the ASP.NET forums.
Saturday, November 11, 2017 7:33 PM -
The HTTP response code returned for the first request is 500 Internal Server Error. 2nd time its 200.Saturday, November 11, 2017 9:18 PM
-
The HTTP response code returned for the first request is 500 Internal Server Error. 2nd time its 200.
The 500 code means that program through an exception that was unhandled.Saturday, November 11, 2017 11:02 PM -
Hi Sameer,
According to your question is more related to ASP.NET, you should post a new thread to ASP.Net Forum for suitable support.
The Visual C# discuss and ask the C# programming language, IDE, libraries, samples and tools . If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution .
Sincerely,
Neil Hu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Monday, November 13, 2017 8:32 AM