开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜