TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nadeem Nasir
NA
1
1.7k
How to POST data from ASP.net website to Php (wordpress)
Jan 7 2013 5:35 AM
Hi,
I want to post data (form values ) From my asp.net website to php website. The php website have contact us form, user fill the form and click on submit button to send the form. on successfully submission user get email for confirmation. I want to do that process from my asp.net website. So that I programatically fill the form and send the request. I write the following code and im getting the response but confirmation email is not working. any help please.
public string HttpPost(string uri, string parameters)
{
// parameters: name1=value1&name2=value2
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(parameters);
Stream os = null;
try
{ // send the Post
webRequest.ContentLength = bytes.Length; //Count bytes to send
os = webRequest.GetRequestStream();
os.Write(bytes, 0, bytes.Length); //Send it
}
catch (WebException ex)
{
lblError.Text = ex.Message + "HttpPost: Request error";
}
finally
{
if (os != null)
{
os.Close();
}
}
try
{ // get the response
WebResponse webResponse = webRequest.GetResponse();
if (webResponse == null)
{ return null; }
StreamReader sr = new StreamReader(webResponse.GetResponseStream());
return sr.ReadToEnd().Trim().ToString();
}
catch (WebException ex)
{
lblError.Text = ex.Message + "HttpPost: Response error";
}
return null;
} // end HttpPost
Reply
Answers (
0
)
how can we integrate api to our application???
Dynamically gridview