Socket Programing By C# in ASP.net -
is possible write socket c# in asp.net ? example can write code perl code in c# , asp.net ? :
> use http::request::common qw(post); > use lwp::useragent; $ua = new > lwp::useragent(agent => 'mozilla/5.0(windows; u; windows nt 5.1; en-us; rv:1.8.0.5)gecko/20060719 firefox/1.5.0.5'); > $ua -> timeout(20); > $req = post 'http://example.com/', > [ login_username => 'mehdi' , login22 => '654321' , go => 'submit']; > $content = $ua->request($req);
please give me example or convert above code c# , asp.net . in advance .
yes, achieve same functionality in .net using webclient class:
class program { static void main() { using (var client = new webclient()) { client.headers[httprequestheader.useragent] = "mozilla/5.0(windows; u; windows nt 5.1; en-us; rv:1.8.0.5)gecko/20060719 firefox/1.5.0.5"; var values = new namevaluecollection { { "login_username", "mehdi" }, { "login22", "654321" }, { "go", "submit" } }; var result = client.uploadvalues("http://example.com", values); // todo: handle result here console.writeline(encoding.default.getstring(result)); } } }
Comments
Post a Comment