views:

132

answers:

4

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?

+9  A: 
<a href="http://www.google.com"&gt;google&lt;/a&gt;
Trimack
Hahaha! Nice one... ;)
Frankie
considering HTML.actionLink produces a html action link I'd say that this is the correct answer!
Matt Smith
+2  A: 
Response.Redirect("http://google.com/");

(It's not really MVC-specific, by the way)

brianreavis
+6  A: 

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.

Joseph
+2  A: 

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"&gt;Click to go to Google</a>.

mc2thaH