好的。我有一个问题,需要在控制器操作中进行一些授权检查。
有授权角色,但可能存在某人具有TypeOnePayment但没有TypeTwo的情况。
[Authorize(Roles = "TypeOnePayment;TypeTwoPayment")]
public ActionResult EnterRevenue(PaymentType payment)
{
payment = "TypeOne"; // This exists for show only.
var permission = string.Concat(payment,"Permission");
if (!SecurityUtility.HasPermission(permission))
{
return View("Unauthorized", "Error");
}
return this.PartialView("_EnterRevenue");
}
但由于这只返回了部分视图,因此“错误”屏幕仅出现在页面的部分视图中。有没有办法重定向到全新的页面?
编辑:EnterRevenue是通过ajax调用检索的。因此,只返回html并将其放置在调用它的视图中。