ojek
ojek

Reputation: 10068

ASP.NET MVC - redirect to external page?

I have this:

public RedirectResult LinkRedirect(string url)
{
    return Redirect(url);
}

And all it does, is redirecting me to http://mysite.com/www.externalsite.com. What am I missing here?

Upvotes: 2

Views: 2268

Answers (1)

Shyju
Shyju

Reputation: 218722

You need to pass a url with http://prefixed to it. Then it will work

Ex: http://www.google.com

So if you want to allow your action method to accept all kind of links( with and without http prefix), you need to write little bit of code to check whether the passed the url parameter value has http prefix and if not, append it.

Upvotes: 4

Related Questions