Last post May 09, 2016 10:01 AM by Yohann Lu
May 02, 2016 10:57 PM|brucey|LINK
Hi folks, is possible to input directly from my website to
i.e. customer inputs their vehicle
registration and make into a web form on my website, I then send this data to
capture the output and display the results back onto my website?
May 03, 2016 01:31 AM|Yohann Lu|LINK
As far as I know, we will try the following two cases.
1: Use Web API
If you use Web API to implement this need. Your only difficulty is to ask this site provides an interface, then you can send data to this website and display the results back to your website.
Learn About ASP.NET Web API:
2: Simulation Website Login
This implementation is more cumbersome, because it has a lot of uncertainty.
You can refer the following post.
Using c#/ASP.NET to programmatically fake a login to a website:
May 03, 2016 02:32 PM|brucey|LINK
Thanks Yohann Lu, unfortunately they will not be releasing an interface anytime soon,
May 03, 2016 03:20 PM|ryanbesko|LINK
It's definitely not a recommended way to do it, but view the source of that page and look for the <form> tag. As long as you submit to the same action, with the same field names, it should process like it was submitted from that site. This is of course
unless they have an anti forgery token on the page, which would make it impossible.
May 03, 2016 07:16 PM|brucey|LINK
May 09, 2016 10:01 AM|Yohann Lu|LINK
You can try the following code.
protected void Button1_Click(object sender, EventArgs e)
string data = "Registration number=136260&Vehicle make=make name";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.check-mot.service.gov.uk/");//post url
// set post headers
request.Method = "POST";
request.KeepAlive = true;
request.ContentLength = data.Length;
request.ContentType = "application/x-www-form-urlencoded";
// write the data to the request stream
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
//get data and display the results back onto your website
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string myResponse = "";
using (System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream()))
myResponse = sr.ReadToEnd();
How to use HttpWebRequest and HttpWebResponse in .NET: