Redirect to external URI from ASP.NET MVC controller

Viewed 240010

I'm trying to redirect to external url from an action method but can't get it to work. Can anybody shed some light on my error?

public void ID(string id)
    {
        string url = string.Empty;
        switch (id)
        {
            case "DB2FCB11-579F-4DA2-A68C-A6495B9BAAB5":

                url = "http://www.somesite.com";
                break;
        }
        Response.Redirect(url, true);
    }

Thanks, Chris

4 Answers

Maybe the solution someone is looking for is this:

Response.Redirect("/Sucesso")

This work when used in the View as well.

Try this (I've used Home controller and Index View):

return RedirectToAction("Index", "Home");
Related