I would like to have a async action in a MonoRail basecontroller.
I read the documentation about asynchronous actions http://docs.castleproject.org/Default.aspx?Page=Controllers&NS=MonoRail&AspxAutoDetectCookieSupport=1#Asynchronous_Actions_1
So this is what I did:
public IAsyncResult BeginUploadTags(HttpPostedFile xmlFile, Boolean doUpload)
{
if(IsPost)
{
IAsyncResult iAsyncResult = new AsyncDelegate(upload).BeginInvoke(queryResult, doUpload, ControllerContext.Async.Callback, ControllerContext.Async.State);
return iAsyncResult;
}
// TODO
// if IsPost is false do nothing but return a IAsyncResult object
}
public void EndUploadTags()
{
}
private delegate void AsyncDelegate(List<String> queryResult, Boolean doUpload);
private void upload(List<String> queryResult, Boolean doUpload)
{
// do upload stuff
}
But what do i need to do when IsPost is false?
You would need to return a completed IAsyncResult (with a null AsyncResult value).
You can create a completed result similar to the one at this SO question