0

I have following scenario: I have a web application, with this web application I can create a simple document. I have also two Controllers: the default HomeController and another DocGenController. I would like to return to the DocGen.cshtml-page after finishing a job in the DocGenController. At this time I implemented a normal return: return View(../Home/DocGen.cshtml.

But the problem is: if I use the return View(../Home/DocGen.cshtml)-statement it will take me only back to the page (Case 1)

How can I reach case 2?

controller cases

Yannik
  • 887
  • 3
  • 9
  • 29

2 Answers2

1

You should use the RedirectToAction to redirect form one controller to another view/controller. Here is an answer using the redirect with parameters.

Community
  • 1
  • 1
Ross Bush
  • 14,648
  • 2
  • 32
  • 55
1

Instead of return View("~/Views/Home/DocGen.cshtml");

Try

return RedirectToAction("Index","Home");

RedirectToAction method will send a 302 response to the client with /Home/Index as the location header value. The client browser will issue a new Http request for this url.

Shyju
  • 214,206
  • 104
  • 411
  • 497