Server cannot set content type after HTTP headers have been sent

后端 未结 6 1116
离开以前
离开以前 2020-12-20 15:42

I get an error (Server cannot set content type after HTTP headers have been sent.) on the following code (ContentType line). What should I change?



        
6条回答
  •  难免孤独
    2020-12-20 16:02

    Do you need to set the content type? This solution should not be overlooked, because you may find your code to work perfectly without the need to explicitly define the content type for the type of response you are sending. So removing the following line should make the error go away, and may very well do so without introducing new problems (of course you'll want to test this against your scenario):

    response.ContentType = "text/plain";

提交回复
热议问题