Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

WebRequestExtension

Since I see a lot of people still use the old and deprecated WebRequest (yes it still has its uses sometimes, but there are better alternatives) I decided to release this. It is an extension method so adding headers and setting postdata becomes much easier and you can send a request in as little as 2 lines.

https://gist.github.com/GekkeVent/c3b876...41c428f9a8

Example
Code
NameValueCollection headers = new NameValueCollection()
{
    {"Accept", "*/*"}
};
HttpWebRequest request = WebRequest.CreateHttp("url");
request.SetHeaders(headers);
string source = request.GetSource();
oooh very useful, I also made something like this almost a month ago.
You should add an override for SetPost to be compatible with a NameValueCollection...
That'd be nice to see.
[Image: PVoDiqS.png]
(Jan 21, 2017 10:46 PM)Cecilia Wrote:  You should add an override for SetPost to be compatible with a NameValueCollection...
That'd be nice to see.

Never thought about that. How about FormUrlEncodedContent though?
(Jan 21, 2017 10:49 PM)Ninja Wrote:  Never thought about that. How about FormUrlEncodedContent though?

I don't think that's available in 4.0 (sadface).
I guess you can use that :/
[Image: PVoDiqS.png]
HttpWebRequest isn't deprecated, only its constructors are. See: https://msdn.microsoft.com/en-us/library...x#Anchor_6

A good alternative is HttpClient, though.
(Jan 22, 2017 05:10 AM)Dialog Wrote:  HttpWebRequest isn't deprecated, only its constructors are. See: https://msdn.microsoft.com/en-us/library...x#Anchor_6

A good alternative is HttpClient, though.

What I mean is its old. There are better alternatives like WebClient and HttpClient (only in 4.0+).
Thank you for the code snippet. I didn't know about this method.
what happend? i was looking for a web request class and remembered that you made one and now that i need it its gone...
(May 13, 2017 08:17 AM)abratar Wrote:  what happend? i was looking for a web request class and remembered that you made one and now that i need it its gone...

I dont know what happened to the link. Here it is again:
https://gist.github.com/GekkeVent/c3b876...41c428f9a8
(May 13, 2017 06:18 PM)Ninja Wrote:  I dont know what happened to the link. Here it is again:

hey can you PM me your skype, im interested in your services
(Jan 22, 2017 09:10 PM)Ninja Wrote:  What I mean is its old. There are better alternatives like WebClient and HttpClient (only in 4.0+).

Depending on the task, WebClient may not be able to do it but WebRequest can.🤝
(May 16, 2017 06:01 AM)Ast0r Wrote:  Depending on the task, WebClient may not be able to do it but WebRequest can.🤝

I do agree that WebRequests allows for easier 'low level' control over the WebClient. You can however inherit WebClient and add cookie support and what not.
I do agree that WebRequests allows for easier 'low level' control over the webrequest 😧
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(May 16, 2017 08:45 AM)HFDone Wrote:  I do agree that WebRequests allows for easier 'low level' control over the webrequest 😧

Meant WebClient. Fixed it.