当前位置: 首页>>代码示例>>C#>>正文


C# WebRequest.GetResponse方法代码示例

本文整理汇总了C#中WebRequest.GetResponse方法的典型用法代码示例。如果您正苦于以下问题:C# WebRequest.GetResponse方法的具体用法?C# WebRequest.GetResponse怎么用?C# WebRequest.GetResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebRequest的用法示例。


在下文中一共展示了WebRequest.GetResponse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FixedUpdate

    void FixedUpdate()
    {
        Debug.Log("sending HTTP request! to:");
            Debug.Log(url);
            mycoord = WebRequest.Create(url);
            Stream objStream;
            objStream = mycoord.GetResponse().GetResponseStream();
        StreamReader objReader = new StreamReader(objStream);

            sLine = objReader.ReadLine ();
            Debug.Log("Got response!");
            if(sLine.Length > 4) {
                coordinates = sLine;
            }

        Debug.Log(coordinates);

        int x = System.Convert.ToInt32 (coordinates [1]);
        int y = System.Convert.ToInt32 (coordinates [3]);
        float newX = 0 + (x * 2);
        newX -= 96; //for some reason unity jumps my cardboard main to 96,-96
        float newZ = 0 - (y * 2);
        newZ += 96;
        transform.position = new Vector3(newX, 1.5f,newZ);
    }
开发者ID:nieknooijens,项目名称:VRFloorTrackingResearch,代码行数:25,代码来源:playercontrollerWorksbutwithLag.cs

示例2: SendPostRequest

        /// <summary>
        /// Send a simple Post request
        /// </summary>
        /// <param name="ip">IP of client</param>
        /// <returns></returns>
        /// <remarks>Used port 80</remarks>
        public static string SendPostRequest(string ip)
        {
            WebRequest webRequest = new WebRequest(ip, "POST");
            var response = webRequest.GetResponse();

            return response;
        }
开发者ID:Richard210363,项目名称:Haptic-Theatre-Vibings-Control,代码行数:13,代码来源:HTTPManager.cs

示例3: GetHttpWebResponse

    protected static string GetHttpWebResponse(WebRequest webRequest)
    {
        StreamReader responseReader = null;
        string responseData;
        try
        {
            responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
            responseData = responseReader.ReadToEnd();
        }
        finally
        {
            webRequest.GetResponse().GetResponseStream().Close();
            responseReader.Close();
        }

        return responseData;
    }
开发者ID:coolcode,项目名称:app,代码行数:17,代码来源:BaseHttpRequest.cs

示例4: ReadResponse

 private string ReadResponse(WebRequest request)
 {
     using (var responseStream = request.GetResponse().GetResponseStream())
     {
         using (var respReader = new StreamReader(responseStream))
         {
             return respReader.ReadLine();
         }
     }
 }
开发者ID:Snowyo,项目名称:ProtonetApp,代码行数:10,代码来源:Protonet.cs

示例5: GetResponseAsync

 public override Task<WebResponse> GetResponseAsync(WebRequest request) => Task.Run(() => request.GetResponse());
开发者ID:Corillian,项目名称:corefx,代码行数:1,代码来源:FileWebRequestTest.cs

示例6: GetWebReponseLogErrors

 /// <summary>
 /// Get the web response; log any error codes that occur and rethrow the exception.
 /// This allows us to get error log data with detailed information
 /// </summary>
 /// <param name="webRequest"></param>
 /// <returns></returns>
 protected WebResponse GetWebReponseLogErrors(WebRequest webRequest, string description)
 {
     string requestUri = webRequest.RequestUri.ToString();
     try
     {
         return webRequest.GetResponse();
     }
     catch (WebException webException)
     {
         AttemptToLogWebException(webException, description + " (" + requestUri + ") ", this.StatusLog);
         throw webException;
     }
 }
开发者ID:tableau,项目名称:TabMigrate,代码行数:19,代码来源:TableauServerSignedInRequestBase.cs

示例7: requestString

		public string requestString (WebRequest wb)
		{
				WebResponse webResponse = wb.GetResponse ();
				StreamReader reader = new StreamReader (webResponse.GetResponseStream ());
				string response = reader.ReadToEnd ();
				reader.Close ();
				webResponse.Close ();
				return response;
		}
开发者ID:jenstuxen,项目名称:AISUnity,代码行数:9,代码来源:AisViewClient.cs

示例8: Ping

    public bool Ping(string osVersion, string cjVersion, string machineID)
    {
        requestPingAborting = false;

        // Create a request using a URL that can receive a post.
        requestPing = WebRequest.Create (serverUrl + "/ping");

        // Set the Method property of the request to POST.
        requestPing.Method = "POST";

        // Set the ContentType property of the WebRequest.
        requestPing.ContentType = "application/json";

        // Creates the json object
        JsonObject json = new JsonObject();
        json.Add("os_version", osVersion);
        json.Add("cj_version", cjVersion);
        json.Add("machine_id", machineID);

        // Converts it to a String
        String js = json.ToString();

        // Writes the json object into the request dataStream
        Stream dataStream;
        try {
            dataStream = requestPing.GetRequestStream ();
        } catch {
            this.ResultMessage =
                string.Format(Catalog.GetString("You are not connected to the Internet\nor {0} server is down."),
                serverUrl);
            return false;
        }
        if(requestPingAborting) {
            LogB.Information("Aborted from PingAbort");
            return false;
        }

        dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);

        dataStream.Close ();

        // Get the response.
        WebResponse response;
        try {
            response = requestPing.GetResponse ();
        } catch {
            this.ResultMessage =
                string.Format(Catalog.GetString("You are not connected to the Internet\nor {0} server is down."),
                serverUrl);
            return false;
        }
        if(requestPingAborting) {
            LogB.Information("Aborted from PingAbort");
            return false;
        }

        // Display the status (will be 201, CREATED)
        Console.WriteLine (((HttpWebResponse)response).StatusDescription);

        // Clean up the streams.
        dataStream.Close ();
        response.Close ();

        this.ResultMessage = "Ping sent.";
        return true;
    }
开发者ID:GNOME,项目名称:chronojump,代码行数:66,代码来源:json.cs


注:本文中的WebRequest.GetResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。