if a controller action redirects to external url, what do you return in the function?
i have a function and i am unclear what i should return from this?
public ActionResult LoadExternalURL()
{
Response.Redirect("http://www.google.com");
// what do i ret开发者_如何学JAVAurn here ??
}
Instead of calling Response.Redirect it's easier to use the built in RedirectResult ActionResult as follows:-
return Redirect("http://www.google.com");
This will also improve the testability of your code (you don't have to muck around mocking the HTTP context) and instead you can just test the Url property of the returned action result.
精彩评论