leo*_*ora 3 asp.net-mvc hyperlink
我有一个功能,我不清楚我应该从这回来?
public ActionResult LoadExternalURL()
{
Response.Redirect("http://www.google.com");
// what do i return here ??
}
Run Code Online (Sandbox Code Playgroud)
而不是调用Response.Redirect,更容易使用内置的RedirectResult ActionResult,如下所示: -
return Redirect("http://www.google.com");
Run Code Online (Sandbox Code Playgroud)
这也将提高代码的可测试性(您不必嘲笑模拟HTTP上下文),而只需测试返回的操作结果的Url属性.
| 归档时间: |
|
| 查看次数: |
1748 次 |
| 最近记录: |