Creating a JSON Header on ASP.NET

后端 未结 2 604
陌清茗
陌清茗 2020-12-30 03:20

I am converting a script from PHP to ASP.net C#. In PHP, i could use something like:

header(\'Content-type: text/json\');

header(\'Content-type: application/

相关标签:
2条回答
  • 2020-12-30 03:33
    Response.ContentType = "application/json";
    

    or more generally

    Response.Headers.Add("Content-type", "text/json");
    Response.Headers.Add("Content-type", "application/json");
    
    0 讨论(0)
  • 2020-12-30 03:48

    Additional info about JerSchneid's answer

    If you got an error message like this:

    This operation requires IIS integrated pipeline mode.

    You can use this way:

    Response.AddHeader("Content-type", "text/json");
    
    0 讨论(0)
提交回复
热议问题