我有一个功能,我不清楚我应该从此返回什么?
public ActionResult LoadExternalURL()
{
Response.Redirect("http://www.google.com");
// what do i return here ??
}
答案 0 :(得分:5)
不是调用Response.Redirect,而是使用内置的RedirectResult ActionResult更容易,如下所示: -
return Redirect("http://www.google.com");
这也将提高代码的可测试性(您不必嘲笑模拟HTTP上下文),而只需测试返回的操作结果的Url属性。