我正在嘗試使用POST方法在ASP.NET中以編程方式發出Web請求。 我想用web請求發送POST參數。類似這樣的:如何將對象作爲POST參數發送到ASP.Net Web請求?
LoginData obj = new LoginData();
obj.OSVersion = deviceInformation.OperatingSystem;
obj.DeviceModel = deviceInformation.FriendlyName;
string URI = "https://XXXXXXXXX.azure-mobile.net/user/logsuserin";
HttpWebRequest GETRequest = (HttpWebRequest)HttpWebRequest.Create(new Uri(URI, UriKind.RelativeOrAbsolute));
GETRequest.Method = "POST";
GETRequest.ContentType = "application/x-www-form-urlencoded";
GETRequest.Headers["applicationKey"] = "UFakeKkrayuAeVnoVAcjY54545455544";
//GETRequest.Parameters.add(obj);
顯然,註釋行不起作用。我如何實現這一目標?
如何通過發送我的obj作爲params來獲得響應?
在此先感謝, Hemanth。
感謝艾登回覆 request.ContentLength = objBytes.Length; Request.Contentlenght沒有獲取情報 – hemanth
而在LoginData類.GetProperties中也沒有獲得智能 – hemanth