好的。所以我有一個問題,我需要在控制器操作中進行一些授權檢查。ASP.Net MVC從控制器的局部視圖重定向到不同控制器的全視圖
有授權的角色,但它可能存在一些別人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被返回,它被放置在它被調用的視圖中。
你在哪裏使用這個局部視圖?在ajax或Html.Action? – 2014-10-29 18:59:07
它使用ajax調用進行檢索,並在調用成功時將新的html插入到html中。 – ELepolt 2014-10-29 19:07:14
你應該讀這:http://stackoverflow.com/questions/199099/how-to-manage-a-redirect-request-after-a-jquery-ajax-call – 2014-10-29 19:28:11