Send webrequest with parameter in c#

C# webrequest with parameters: Here in this article will see how to pass a parameter with webrequest in c#, i.e making web request with some parameters.

In c# by using HttpWebRequest we create a new webrequest,  and now to send parameters we use query string request.

This is how we send web requests with the parameter in c#.

The Below written code will generate a web request and send it with the parameter in C#.

Stream objStream;
StreamReader objSR;
System.Text.Encoding encode = System.Text.Encoding.GetEncoding("utf-8");

string str = "" + "abc";
HttpWebRequest wrquest = (HttpWebRequest)WebRequest.Create(str);
HttpWebResponse getresponse = null;
getresponse = (HttpWebResponse)wrquest.GetResponse();

objStream = getresponse.GetResponseStream();
objSR = new StreamReader(objStream, encode, true);
string strResponse = objSR.ReadToEnd();

Thank you for reading, pls keep visiting this blog and share this in your network. Also, I would love to hear your opinions down in the comments.

PS: If you found this content valuable and want to thank me? 👳 Buy Me a Coffee

Subscribe to our newsletter

Get the latest and greatest from Codepedia delivered straight to your inbox.

Post Comment

Your email address will not be published. Required fields are marked *