Arun
Arun

Reputation: 1482

Index View not redirecting from another action

I have a Controller action for download file. And after download I trying to redirect to Index view of the same controller. But it is not redirecting

here is my download Action

public ActionResult Download(MemoryStream docStream)
{
  byte[] bytes = docStream.ToArray();
                    docStream.Close();
                    Response.Clear();
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + DocumentInfo.DocumentName + "");
                    Response.AddHeader("Content-Length", bytes.Length.ToString());
                    Response.ContentType = "application/octet-stream";
                    Response.BinaryWrite(bytes);
return View("~/Views/DocumentDownload/Index.cshtml");
    }

Can any one help why it is not redirecting . Thanks in advance

Upvotes: 0

Views: 171

Answers (2)

Shashank Sood
Shashank Sood

Reputation: 480

Just add the name "Index" inside view. E.g.

return View("Index");

Upvotes: 0

kkakkurt
kkakkurt

Reputation: 2800

You can use:

return RedirectToAction("Index");

Upvotes: 1

Related Questions