Adding HTTP request header to WCF request

后端 未结 2 1605
长发绾君心
长发绾君心 2021-02-14 13:40

I have a WCF service consume by both AJAX and C# application,
I need to send a parameter through the HTTP request header.

On my AJAX I have added the following and i

2条回答
  •  自闭症患者
    2021-02-14 14:02

    Make a new WebRequest object of type HttpWebRequest. Set the header and get the response.

    WebRequest req = HttpWebRequest.Create("myURL") as HttpWebRequest;
    req.Headers.Add("AdminGUID", "value");
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    

    for a more in depth example of webrequest, see this page

提交回复
热议问题