我正在開發一個應用程序,用於從xml feed中讀取數據。xml源包含大量數據,大約接近100MB。因此,從Feed會話超時讀取數據時發生在兩者之間。在asp.net中從xml源讀取大數據時避免超時
任何人都可以建議我如何避免超時。
我也試過延長執行時間和請求長度,但仍然沒有解決問題。
<httpRuntime executionTimeout="100000000" maxRequestLength="2097151"
useFullyQualifiedRedirectUrl="false" minFreeThreads="8"
minLocalRequestFreeThreads="4" appRequestQueueLimit="100"
enableVersionHeader="true" />
代碼從URL中讀取XML數據:
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sUrl);
HttpWebResponse wr = (HttpWebResponse)wrGETURL.GetResponse();
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];
if (wr.StatusCode == HttpStatusCode.OK)
{
Stream resStream = wr.GetResponseStream();
string tempString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tempString);
}
}
}
什麼*方法*用於讀取XML文件?你*上傳文件? – adatapost
@AVD:我編輯帖子並顯示了我用來從Feed中讀取數據的方法。 –
看看SO線程[1](http://stackoverflow.com/questions/676274/what-is-the-best-way-to-parse-big-xml-in-c-sharp-code), [2](http://stackoverflow.com/questions/468948/in-c-sharp-what-is-the-best-way-to-parse-large-xml-size-of-1gb),[3] (http://stackoverflow.com/questions/55828/best-practices-to-parse-xml-files),[4](http://stackoverflow.com/questions/7671958/reading-large-xml-documents-中網) – adatapost