get请求是否需要内容类型和接受标头?

Jui*_*est 0 asp.net

我正在发出网络请求,方法是 get。我需要提及 content-Type 并接受 get 方法吗?或者只需要 post 方法

string strURL = "web address";
        Uri uri = new Uri(strURL);

 HttpWebRequest webRequest = System.Net.WebRequest.Create(uri) as HttpWebRequest;   

          webRequest.Method = WebRequestMethods.Http.Get
          webRequest.ContentType = "application/json";
          webRequest.Accept = "application/json";
Run Code Online (Sandbox Code Playgroud)

Sac*_*hin 5

content-type:GET 请求中不需要它,因为您不会在请求正文中发送任何内容。

content-type表示发送给接收者的entity-body的媒体类型。

接受:这取决于您的要求。如果您想限制响应中的媒体类型,则可以使用它,否则请保留它。

Accept 请求头字段可用于指定响应可接受的某些媒体类型。