[英]how to send already prepared in string http request in C#
Http 請求作為字符串 C#
我想發送 http 請求,因為它是從用戶給我的,沒有任何更改。
從用戶我得到字符串
GET / HTTP/1.1
Host: examplesite.com
Content-Length: 15
所以我想按原樣發送它而不進行任何更改或解析,是否有任何庫可以在 C# 中執行此操作?
您如何捕獲用戶准備的 URL?
如果您嘗試創建一個簡單的請求,可用最少的信息,您可以使用以下內容:
public static void Main()
{
// User Prepared Url
var url = "https://www.google.com";
// Create a 'WebRequest' object with the specified url.
WebRequest myWebRequest = WebRequest.Create(url);
// Send the 'WebRequest' and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse();
// Release resources of response object.
myWebResponse.Close();
}
檢查 Url 是否有效等沒有邏輯。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.