. NET web page for application login

Source: Internet
Author: User

1. VB. NET code

 

Imports system. textimports system. netimports system. iopublic class uwantslogin private loginid as string = "spang" Private loginpass as string = "123456" Public sub new () dim encoding as new utf8encoding dim postdata as string = "username =" & loginid & "& Password =" & loginpass dim data () as byte = encoding. getbytes (postdata) 'Prepare Web Request dim request as httpwebrequest = ctype (webrequest. crea Te ("http://www5.uwants.com/logging.php? Action = login "), httpwebrequest) request. method = "Post" request. contenttype = "application/X-WWW-form-urlencoded" request. contentlength = data. length dim newstream as stream = request. getrequeststream () 'send the data newstream. write (data, 0, Data. length) newstream. close () 'Get response dim response as httpwebresponse = ctype (request. getresponse (), httpwebresponse) dim reader as streamreader = new streamreader (response. getresponsestream (), system. text. encoding. getencoding ("big5") dim content as string = reader. readtoend () end subend class

Ii. Visual C # code

 

Using Microsoft. visualBasic; using system. collections; using system. collections. generic; using system. data; using system. diagnostics; using system. text; using system. net; using system. io; public class uwantslogin {private string loginid = "spang"; private string loginpass = "123456"; Public uwantslogin () {utf8encoding encoding = new utf8encoding (); string postdata = "username =" + loginid + "& passwo RD = "+ loginpass; byte [] DATA = encoding. getbytes (postdata); // Prepare web requesthttpwebrequest request = (httpwebrequest) webrequest. Create (" http://www5.uwants.com/logging.php? Action = login "); Request. method = "Post"; request. contenttype = "application/X-WWW-form-urlencoded"; request. contentlength = data. length; stream newstream = request. getrequeststream (); // send the datanewstream. write (data, 0, Data. length); newstream. close (); // get responsehttpwebresponse response = (httpwebresponse) request. getresponse (); streamreader reader = new streamreader (response. getresponsestream (), system. text. encoding. getencoding ("big5"); string content = reader. readtoend ();}}

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.