أعتقد أن لديك خياران:
الخيار الأول هو القيام بذلك على جانب العميل باستخدام AJAX: (http://api.jquery.com/jquery.ajax/
يمكن أن يبدو الرمز شيئًا مثل:
function CallOtherSite(otherSiteUrl) {
$.ajax({
url: otherSiteUrl,
cache: false,
success: function (html) {
//This will be the html from the other site
//parse the html/xml and do what you need with it.
}
});
نظرًا لأنه يتم ذلك مع JavaScript على جانب العميل ، فمن المرجح أن تواجه مشكلة مع CORS. ((http://blogs.msdn.com/b/carlosfigueira/archive/2012/02/20/implementing-cors-support-in-asp-net-web-apis.aspx)
الخيار الآخر والخيار الأفضل في رأيي هو القيام بذلك على جانب الخادم. (إما في وحدة تحكم أو عرض مع الحلاقة) (سيكون أسهل بكثير في Contoller ...)
try
{
var request = (HttpWebRequest)WebRequest.Create(urlToOtherSite);
request.Accept = "application/xml";
request.Method = "GET";
webResponse = (HttpWebResponse)request.GetResponse();
sr = new StreamReader(webResponse.GetResponseStream());
string responseText = sr.ReadToEnd();
}
catch(Exception ex)
{
}
finally
{
if (sr != null) { sr.Close(); }
if (webResponse != null) { webResponse.Close(); }
}
ثم يمكنك استخدام StreamReader للحصول على HTML/XML والقيام بما ستفعل به.
أتمنى أن يساعدك هذا...