The API itp.GetSessionStoragePath provides custom aspx pages with a means of storing files that belong to a session, i.e., a model run, across requests.
String GetSessionStoragePath (String sessionid,
String element,
String extension)
Parameters:
sessionid should contain the ITP/Server session ID for which the storage path should be retrieved.element indicates the name of the storage element.extension defines the extension of the file name that is generated.The return value is a full path to a storage location. This function provides the following stability guarantee: for the same values of sessionid, element and extension, this function always returns the same file name when used in the same ASP.NET session. If the ASP.NET session is different, or if the ASP.NET session ID is the same but the session has expired since the previous time the function was called, the answer may be different. Because of the stability guarantee, this function can be used to provide short term temporary storage that is valid across requests.
Here follows an example of how the GetSessionStoragePath API can be used to get the result document of a prepared model run from the modelend.aspx page, and then download it through a separate URL. In the modelend.aspx page the result document is downloaded using an ITP/Server service to a session storage path, as follows:
String sessionid = Request.QueryString["sessionid"];
// Get a storage path that stays the same in the next page
String path = GetSessionStoragePath (sessionid,
"result", "doc");
// Create a Job object to call ITP/Server service GetMyResult
Aia.ITP.Server.Job job = itp.CreateITPServerJob (this,
"GetMyResult");
// Register a handler for the FileDownload event that tells
// the Job object to download the file to the path we just
// calculated.
job.FileDownload +=
new delegate (String file)
{
return path;
};
// Submit the job to ITP/Server.
job.Submit();
The modelend page now provides the user with a link to a different page "downloadresult.aspx?sessionid=<the session id>" to download the document. This page sends the stored document to the web browser:
String sessionid = Request.QueryString["sessionid"];
String path = GetSessionStoragePath (sessionid,
"result", "doc");
Response.ContentType = "application/msword";
Response.TransmitFile(path);