Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

C# webclient submit form

var strId = UserId_TextBox.Text;
var strName = Name_TextBox.Text;

var encoding=new ASCIIEncoding();
var postData="userid="+strId;
postData += ("&username="+strName);
byte[]  data = encoding.GetBytes(postData);

var myRequest =
  (HttpWebRequest)WebRequest.Create("http://localhost/MyIdentity/Default.aspx");
myRequest.Method = "POST";
myRequest.ContentType="application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
var newStream=myRequest.GetRequestStream();
newStream.Write(data,0,data.Length);
newStream.Close();

var response = myRequest.GetResponse();
var responseStream = response.GetResponseStream();
var responseReader = new StreamReader(responseStream);
var result = responseReader.ReadToEnd();

responseReader.Close();
response.Close();
Comment

PREVIOUS NEXT
Code Example
Csharp :: winform fixed size 
Csharp :: Rotating an object in Unity usign Physics 
Csharp :: how to make randomizer c# 
Csharp :: C# ValidationAttribute required when 
Csharp :: exe path c# 
Csharp :: get script directory c# 
Csharp :: c# out parameter 
Csharp :: c# internalsvisibleto 
Csharp :: c# int to string date conversion 
Csharp :: game maker transparent 
Csharp :: request a pricipal permission 
Csharp :: cant see my classes in inspector 
Csharp :: unity create a textbox in inspector 
Csharp :: button event trigger wpf 
Csharp :: c# datagridview multiple row selection without control 
Csharp :: visual studio console.writeline not showing in output window 
Csharp :: c# ip address to string 
Csharp :: asp net core dependency injection factory with parameters 
Csharp :: how prevent user remove file linux 
Csharp :: serilog asp.net 5 
Csharp :: Save variable unity 
Csharp :: linq convert list to another list 
Csharp :: convert list of string to dictionary 
Csharp :: hashtable in c# 
Csharp :: how to make a cast in c# 
Csharp :: matrix transpose c# 
Csharp :: link list in c# 
Csharp :: round image unity 
Csharp :: access server name or ip c# get 
Csharp :: system.componentmodel.dataannotations hide field 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =