For example I have some view with action link:
@Html.ActionLink("Action", "Controller")
Action action returns some view:
public ActionResult Action()
{
string someModelForView = "some url i need to redirect after view was fully loaded";
return View("SomeView", someModelForView);
}
What I need is to redirect user to url, defined in someModelForView model after view was fully loaded, and all javascripts on this page were executed. This view might be empty, without any content, I just need to execute some javascript, and after that redirect user to external page. How can accomplish that?
Once the view has been rendered and the JavaScript loaded, you (the server) have already sent your response (encapsulated in the returned
ActionResult) to the client (the browser). Thus, you cannot let ASP.NET MVC redirect you – the server has finished handling the request.You can use JavaScript redirecting instead, though: