我想送誰擁有不正確的角色到另一個頁面的用戶,但是當我使用:如何將使用不正確角色的用戶(已登錄的用戶)重定向到查看頁面?
return RedirectToAction("Index", "Home");
我得到的錯誤:
Cannot implicitly convert type 'System.Web.Mvc.RedirectToRouteResult' to 'System.Web.Mvc.ViewResult'
這是錯誤的,因爲我是在HTTP GET而不是一個HTTP POST?
這裏是我的代碼,因爲它是:
public ViewResult Index()
{
if (User.IsInRole("Administrator") | User.IsInRole("SuperAdministrator"))
{
//Do Admin Things
return View()
}
else
{
// Send to a different page
return RedirectToAction("Index", "Home"); // I want to do this, but it gives me an error
}
如何重定向用戶根據他們在這種情況下的作用?
謝謝返回你非常。 – Ecnalyr 2012-04-20 12:32:40
我們歡迎..... – Yorgo 2012-04-20 12:33:41