I am having a hard time figuring out how to redirect to an outside source.
in my code, I have
<%= Html.ActionLink("New Name Search", "Index") %>
which will allow me to navigate within the code.
how do I redirect to ...google for example?
I am having a hard time figuring out how to redirect to an outside source.
in my code, I have
<%= Html.ActionLink("New Name Search", "Index") %>
which will allow me to navigate within the code.
how do I redirect to ...google for example?
Response.Redirect("http://google.com/");
(It's not really MVC-specific, by the way)
The purpose of the ActionLink helper is to generate links that will direct the user to a controller action that you've defined.
If you want to navigate the user to an outside source you should just use a regular anchor tag.
If you are redirecting from your controller (or action filter, etc.) you can use the RedirectResult
as your ActionResult
type:
RedirectResult("http://www.google.com");
This is essentially doing a Response.Redirect
, but is the preferred way of sticking with ASP.NET MVC conventions.
If you are just creating a link inside a View
, just use <a href="http://www.google.com">Click to go to Google</a>
.