I want to create user in register form with the help of a program of post method. I have written the following code for it:
New user is not getting created by this code.
In registration page, new user is created.
Code:
string post_data="parul0"; string uri="http://localhost:1161/Register.aspx"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.KeepAlive = false; request.ProtocolVersion = HttpVersion.Version10; request.Method = "POST"; byte[] postBytes = Encoding.ASCII.GetBytes(post_data); request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = postBytes.Length; Stream requestStream = request.GetRequestStream(); requestStream.Write(postBytes, 0, postBytes.Length); requestStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Console.WriteLine(new StreamReader(response.GetResponseStream()).ReadToEnd()); Console.WriteLine(response.StatusCode);
In registration page, new user is created.