Reputation: 1169
in my view I have simple table with link to product:
<td>@Html.ActionLink("View details", "Open","Home",new { id = product.Id, url = product.Url })</td>
In my controller, I am doing some stuff with received data:
public ActionResult Open(int id, string url)
{
productService.AddUserVisit(id);
return RedirectToAction("Index");
}
And after all I am refreshing page. What I want to do is to open passed url
in next page. How can I do that?
Upvotes: 1
Views: 1541
Reputation: 69
Can you just use
return Redirect(url)
Or if you need to go to the Index page first for some reason, you could try
return RedirectToAction("Index", new { url = url });
and obviously accept the url as a string on your index controller.
Hope that helps
Mark
Upvotes: 1
Reputation: 103
I believe you want something similar to this question here: Redirect to external URI from ASP.NET MVC controller
Except you want to do this:
return Redirect(url);
Upvotes: 0