Forums » .NET » ASP.NET »

How to http post method in asp.net C#


Posted Date: 12 Jul 2012      Posted By:: Vijay Khanjode     Member Level: Silver    Member Rank: 1645     Points: 5   Responses: 1



hi

how to send http post method in this code i want to send request with json string to server and server send http response in json formate how to handle this round trip


StringBuilder sb = new StringBuilder();

byte[] buf = new byte[8192];

//do get request
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://www.sampadasoftware.com/aboutus.html?user=HatemSalem");
// request.Method = "POST";
// request.ContentLength = postsourcedata.Length;
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();


Stream resStream = response.GetResponseStream();

string tempString = null;
int count = 0;
//read the data and print it
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);

sb.Append(tempString);
}
}
while (count > 0);
Response.Write(sb.ToString());




Responses

#679957    Author: Anil Kumar Pandey      Member Level: Platinum      Member Rank: 1     Date: 12/Jul/2012   Rating: 2 out of 52 out of 5     Points: 2

Can you please let us know that what is the issue in your code.

You already making use of the POST method. Are you able to execute this code successfully?

Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, DNS MVM



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Regular expression for File upload control
Previous : Excel File data inset into Oracle Database using .NET
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.