In my ASP.NET MVC 3 application, I am trying to use an external search engine.
The search engine is used as following :
I execute a URL with the search parameters I want like this
http://<Domain>/engine/ContactssCore/select?q=QUERY
This will return an XML result, which I am going to parse into C# objects.
My question is, how can I call this URL and get the XML result from my controller ?
您可以使用WebClient.DownloadString方法完成此操作。
An XDocument can load direcly from an external source
var xml = XDocument.Load("http://<Domain>/engine/ContactssCore/select?q=QUERY");
You should probably encode your QUERY parameter before making the request.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.