我有一个 MVC 方法,当前返回 ActionResult - 我不得不做一些更改,并根据业务逻辑我要做一个response.redirect而不是
所以我想做这样的事情:
public ActionResult Index(CountryHomePageType currentPage)
{
if (someVar = true)
{
return View();
}
else
{
Response.redirect("www.website.com")
}
}
但我无法理解Resonse.Redirect不是ActionResult ....
我怎样才能解决这个问题?
答案 0 :(得分:1)
如果您在当前的mvc应用程序之外重定向,可以使用
return Redirect("<your external url>"); // like "https://www.google.com"
如果您想重新安装回主页,可以使用
return RedirectToAction("Index", "Home");
假设您使用默认的mvc设置
如果您要在多个地方进行此项检查,您可能还需要查看https://files.fm/f/nwx8e7je。