从一个控制器我想利用用户到另一个网页的应用程序的相对路径,所以我说是这样的:为什么RedirectToAction失去了应用
return RedirectToAction("Index","ThatPage");
我检查,既ThatPageController
和Index
确实存在。 但它需要浏览器的网址:http://thatpage/
这是怎么回事?
从一个控制器我想利用用户到另一个网页的应用程序的相对路径,所以我说是这样的:为什么RedirectToAction失去了应用
return RedirectToAction("Index","ThatPage");
我检查,既ThatPageController
和Index
确实存在。 但它需要浏览器的网址:http://thatpage/
这是怎么回事?
RedirectToAction的重载位置,您想要转到另一个控制器以及该控制器内的某个方法,它有两个单独的字符串作为参数。
你会想要写:
return RedirectToAction("Index", "Home");
你错过了“标记的方法签名
哦,那只是hanbd输入错字!但是,谢谢我发现这个问题,它不是一个标准的MVC问题所以,这是导致它的一些内部内部代码。 – Travolta
This example when user closes a session
public async Task<ActionResult> Logout()
{
return RedirectToAction("Index", "App");
}
where APP is the controller and Index is the action where I have within the App controller
Appcontroller:
in App controller I have this
public IActionResult Index()
{
return View();
}
请发表您的路由配置(包括任何地区和属性的路由)也。 ,这是一个错字,你没有在'ThatPage'之前的双引号,或者是你的实际代码吗? – NightOwl888