我試圖加載與jQuery和(ASPX)代理遠程rss飼料。我在這個問題上讀了很多問題,但我的情況稍有不同。
我有一個XML文件,其中包含用戶的訂閱。對於每個條目我想加載一些飼料,比如前三個飼料。
我可以正確檢索訂閱列表,但我無法獲取訂閱源條目。代理一直給這個異常:代理ASP不加載外部xml
Riga 22: HttpWebRequest request = (HttpWebRequest) WebRequest.Create(proxyURL);
Riga 23: request.Method = "GET";
Riga 24: HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Riga 25:
Riga 26: if (response.StatusCode.ToString().ToLower() == "ok")
[SocketException (0x274c): Impossibile stabilire la connessione. Risposta non corretta della parte connessa dopo l'intervallo di tempo oppure mancata risposta dall'host collegato 213.92.16.191:80]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +269
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +649
[WebException: Impossibile effettuare la connessione al server remoto.]
System.Net.HttpWebRequest.GetResponse() +1126
Proxy.Page_Load(Object sender, EventArgs e) in c:\Users\andrea\documents\visual_studio_2010\websites\leafhouse\Proxy.aspx.cs:24
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428
這是我的proxy.aspx頁:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
public partial class Proxy : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string proxyURL = string.Empty;
try
{
proxyURL = HttpUtility.UrlDecode(Request.QueryString["u"].ToString());
if (proxyURL != string.Empty)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(proxyURL);
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode.ToString().ToLower() == "ok")
{
string contentType = response.ContentType;
Stream content = response.GetResponseStream();
StreamReader contentReader = new StreamReader(content);
Response.ContentType = contentType;
Response.Write(contentReader.ReadToEnd());
}
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
而且這是我使用jQuery的:
$.ajax({
type: "GET",
url: "proxy.aspx?u=" + encodeURI("http://" + serverAddress + ":82") + "/RSSReaderSubscriptions.xml",
dataType: "xml",
success: function (data) {
$(data).find('url').each(function (index, element) {
if (index < 3) {
$.ajax({
type: "GET",
url: "proxy.aspx?u=" + encodeURI($(this).text()),
dataType: "xml",
success: function (data) {
parseRSS(data);
},
error: function() {
console.log("error");
});
}
});
},
error: function() {
console.log("error");
});
如何我可以使代理加載rss提要?
任何幫助非常感謝!謝謝!
[MSDN](http://www.varindersandhu.in/2010/12/13/asp-net-iis-registration-tool-aspnet_regiis-exe/),有關此工具的更多信息。很高興知道,謝謝! –