0

i have my string text in my variable in C#:

string readText = File.ReadAllText(path);
return readText;

When i call this from my FE, the response type is text/html.

enter image description here

How can i change it in "application/json"? Is there any ChangeResponseType method for a string variable?

Fragola 86
  • 59
  • 1
  • 4
  • If you are using asp.net core add this attribute `[Produces("application/json")]` to your action method – vahid tajari Aug 03 '22 at 08:31
  • 1
    If using asp.net core you could also use this for returning `return this.Content(readText, "application/json");`. Got the information from [here](https://stackoverflow.com/questions/9777731/mvc-how-to-return-a-string-as-json) – Tagz97 Aug 03 '22 at 08:44

0 Answers0