I have a very long running server side process that imports items from an XML file. It needs to run in a simple web page. Importing 3 items takes about 25 seconds due to a very slow running API process and not much can be done about that. In total the process needs to import about 1800 items, so there is no way this can run before the page can complete without timing out. Also I need to give some kind of simple visual progress to the user (importing 37 of 1997 etc.)
I've put the process to import as a stand alone file that takes a query string (x= current row position ; y = total rows ; f = filename saved on server )
Originally I thought that the first request could call the second request etc.
So processXml.aspx ?x=1&y=1997&f=m yfile.xml when completed would reload processXml.aspx ?x=2&y=1997&f=myfil e.xml then processXml.aspx ?x=3&y=1997&f=myfil e.xml etc
however if i use
[sX2 = x+1]
no output is returned to the user
then I thought what about
but this always loads the same page with the same query string, no ideas why, but X does not progress, it stays in a loop where x always equals 1, on page load after the reload x always equals 1, and sX2 always equals 2 but when reloaded x still equals 1
So....
what is a good approach to this?
I'm wondering about using an IFrame maybe and calling it in JavaScript but this would be new territory for me, there must be a good pattern for this sort of thing
Any help very gratefully received :)
I've put the process to import as a stand alone file that takes a query string (x= current row position ; y = total rows ; f = filename saved on server )
Originally I thought that the first request could call the second request etc.
So processXml.aspx ?x=1&y=1997&f=m yfile.xml when completed would reload processXml.aspx ?x=2&y=1997&f=myfil e.xml then processXml.aspx ?x=3&y=1997&f=myfil e.xml etc
however if i use
Code:
string fileName = Request.QueryString["f"].ToString();
string tX = Request.QueryString["x"].ToString();
string tY = Request.QueryString["y"].ToString();
int iX = Convert.ToInt16(tX);
string sX2 = Convert.ToString(iX+1);
///do a long running thing
...
Response.Redirect("processXml.aspx?x=" + sX2 + "&y=" + tY + "&f=" + fileName, true);
no output is returned to the user
then I thought what about
Code:
Response.AppendHeader("Refresh", "0; processXml.aspx?x=" + sX2 + "&y=" + tY + "&f=" + fileName);
So....
what is a good approach to this?
I'm wondering about using an IFrame maybe and calling it in JavaScript but this would be new territory for me, there must be a good pattern for this sort of thing
Any help very gratefully received :)
Comment