0

I have a situation where I am on a controller called customer, and I have an account method which I called using a customer number as the identifier.

I then have an ActionLink that takes me to Arrears task with the task form in a partial view of arrears index. on loading this I store the Request.ServerVariables["http_referer"] so I can use that to return.

When I then use Return Redirect() with the referrer it does the redirect but loads in the partial section like it was loading in an iframe.

Can anyone point me to how to redirect the whole page and not only the partial?

MikeSmithDev
  • 15,731
  • 4
  • 58
  • 89
Graham
  • 47
  • 1
  • 7
  • are you using AJAX to render the partialview? Can you also post some code with views and actions? – ramiramilu Feb 04 '14 at 05:27
  • yes we are using AJAX to call to call and render the partial view. looks like the AJAX is what might be keeping it loading inside itself. Will try and get the snippets of code shortly – Graham Feb 04 '14 at 19:55

2 Answers2

1

Try redirecting to a particular action which will return the the View you want

return RedirectToAction("Index", model);
Gjohn
  • 1,261
  • 1
  • 8
  • 12
  • Doing any kind of Redirect including redirect to action only loads it in the partial views space. – Graham Feb 04 '14 at 19:51
  • Is the View you want to redirect to a partial view as well? – Gjohn Feb 04 '14 at 20:12
  • No I am trying to break out of the AJAX section and send the user back to a complete URL for a full page refresh and the page to go to is a completely different controller. – Graham Feb 04 '14 at 20:28
  • @Graham so how are you making the call to the controller that is doing the redirect? Is it a jQuery ajax post or what is going on? – Gjohn Feb 04 '14 at 20:42
  • The return action is being processed in the controller. looking over comments here helped me find another stackoverflow question that has given me a solution. The post is here [link](http://stackoverflow.com/questions/1538523/how-to-get-an-asp-net-mvc-ajax-response-to-redirect-to-new-page-instead-of-inser). Thanks for the help all. wouldn't have found that post if you hadn't pointed me to the AJAX being the reason for the behaviour. – Graham Feb 04 '14 at 21:04
1

using the following return for the ActionResult return breaks out of the AJAX call and redirects the entire page

    return JavaScript("window.location = 'your specified url'");
Graham
  • 47
  • 1
  • 7
  • how would you recommend having it return a link that the javascript would then know to redirect the full page rather than only the partial view, I need the AJAX to render the way it currently does for the other way to use this form. it is only for one situation that I need to redirect the entire page? – Graham Feb 05 '14 at 01:08