當我進行AJAX調用以接收在此C#代碼中定義的JSON對象時,我必須等待46+秒以接收此對象。該對象本身只有12kb大。是否因爲我的C#代碼(這不需要很長的時間來執行?)是另一回事。我在我的本地主機IIS服務器上測試它。爲什麼我的ajax調用需要這麼長時間?
這是我的代碼:
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult LoadAudit(int id, string sheet)
{
FactsCustomerRepository<Cateringaudit> repo = new FactsCustomerRepository<Cateringaudit>();
//IQueryable<Cateringaudit> result = repo.GetAll(i => i.State == 1);
Cateringaudit result1 = repo.Get(id);
WorkBook wb = new WorkBook();
wb.read(new MemoryStream(result1.ExcelData));
object[] jsonObjects = new object[3];
//sheetnames to collect data from
string[] sheetNames = { "contract", "proces", "output" };
//itterate trough all sheets in excel file
for (int sheetCount = 0; sheetCount < sheetNames.Length; sheetCount++)
{
wb.Sheet = wb.findSheetByName(sheetNames[sheetCount]);
//Create new array with same lenght as rows with data
Dictionary<string, string[]> excelData = new Dictionary<string, string[]>();
//iterate trough all rows in worksheet
for (int i = 1; i < wb.LastRow + 2; i++)
{
excelData.Add(blabla);
jsonObjects[sheetCount] = excelData;
}
}
return Json(jsonObjects);
}
是以上所有代碼需要的問題? –
嘗試記錄重要行的每一步。日誌應該有時間戳。然後,你可以從那裏調查。 –
問題在哪裏涉及到上面的代碼?這絕對與AJAX毫無關係。請修改您的問題 – Radinator