coure2011
coure2011

Reputation: 42444

Why Response.Redirect is not working

here is my C# code in postback action

if (something-true)
   Response.Redirect("~/Admin/Home",true);

When I debug, I can see that executor come on this line but then also move to the next lines and finally go to the end and return View(). Why I am not redirecting to ~/Admin/Home??? After posting back its showing the main root url.

Upvotes: 1

Views: 2233

Answers (1)

Colin Mackay
Colin Mackay

Reputation: 19175

Have you considered using a RedirectToAction instead:

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

I'm assuming your controller is HomeController and your action method name is Admin.

Using RedirectToAction would fit the MVC paradigm much better.

Upvotes: 1

Related Questions