为什么Redirect()不在控制器中执行?

时间:2015-11-04 17:21:11

标签: asp.net-mvc controller

我在Method1()中。满足方法中的条件,因此Redirect()代码执行:

//SalesController
[HttpPost]
public ActionResult Method1(SalesViewModel model)
{
//some code here

if (condition) {
  return Redirect(localhost:3000/page1.html);
}

return View("SalesGraphDisplay", model);

我最终登录的网址不是localhost:3000/page1.html,而是localhost:3000/Sales/Method1

怎么可能?视图没有返回,所以重定向是我应该最终的位置吗?

1 个答案:

答案 0 :(得分:0)

我猜你是指同一个解决方案中的页面?

1:你可以创建一个cshtml文件和控制器吗?我认为HTML文件的变化不大。

2:创建一个FilePathResult,从未尝试过,但请阅读它。

 return new FilePathResult("~/page1.html", "text/html");