I am a new user of umbraco but i really need this solution.
I have a form, it is sending email to me, all fields,
But now i need to send email to me also the same data i have to send to third party url,
Http requests have nothing in common with Umbraco or any other stuff. I suppose you have some controller and you're trying to send this POST request right there. You can do it this way:
using (var client = new HttpClient())
{
var values = new Dictionary<string, string>
{
{ "key1", "value1" },
{ "key2", "value2" }
};
var encodedContent = new FormUrlEncodedContent(values);
var response = await client.PostAsync(url, encodedContent);
}
Adding http request
I am a new user of umbraco but i really need this solution. I have a form, it is sending email to me, all fields, But now i need to send email to me also the same data i have to send to third party url,
What can i do?
Using these ideas but not working?
string url = "3rd Party Url";
StringBuilder postData = new StringBuilder();
postData.Append("firstname=" + HttpUtility.UrlEncode(txtFirstName.Text) + "&"); postData.Append("lastname=" + HttpUtility.UrlEncode(txtLastName.Text));
//ETC for all Form Elements
// Now to Send Data. StreamWriter writer = null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postData.ToString().Length; try { writer = new StreamWriter(request.GetRequestStream()); writer.Write(postData.ToString()); } finally { if (writer != null) writer.Close(); }
Response.Redirect("NewPage");
Http requests have nothing in common with Umbraco or any other stuff. I suppose you have some controller and you're trying to send this POST request right there. You can do it this way:
is working on a reply...