This is a migrated thread and some comments may be shown as answers.

Upload and redirect to another action

2 Answers 76 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Samir
Top achievements
Rank 1
Samir asked on 09 Jun 2011, 12:59 AM
Hi there,

Is there any way tha I can upload asynchronously and then redirect to another action. I know this is possible using if uploading synonymously.

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 10 Jun 2011, 08:59 AM
Hello Samir,

The asynchronous upload is much like any other AJAX request - you can't redirect the calling page from it.

The redirect must be done with JavaScript in the OnSuccess handler:
function onSuccess(e) {
    window.location.href = e.response.nextActionUrl;
}

The nextActionUrl is set by the Save action:
[HttpPost]
public ActionResult Save(IEnumerable<HttpPostedFileBase> attachments)
{
    return Json(new { nextActionUrl = Url.Action("Action", "Controller") }, "text/plain");
}

For more information on how to send data back to the Upload - Receiving metadata from the upload action

Greetings,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Samir
Top achievements
Rank 1
answered on 16 Jun 2011, 04:49 AM
Brilliant, that's what I was looking for.

Thanks very much.
Tags
Upload
Asked by
Samir
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Samir
Top achievements
Rank 1
Share this question
or