1
我創建了一個名爲[ValidateUrlAttribute]操作篩選,我想用這個動作過濾器除了在我的class.I一些方法嘗試這以後的事,但它不工作如何僅爲一種方法禁用Actionfilter?
public class ActionExemptionsAttribute : ActionFilterAttribute
{
public string Exemption { get; set; }
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext.RouteData.GetRequiredString("action") == Exemption)
return;
base.OnActionExecuting(filterContext);
}
}
介意分享一些代碼?而你試過的什麼都不起作用? – shashwat
我想你可以在這裏找到你需要的東西:http://stackoverflow.com/questions/9953760/how-to-disable-a-global-filter-in-asp-net-mvc-selectively – Charmander
[ActionExemptions(Exemption =「GetUserDetailsForCreatePassword」)]在控制器我試過這樣但它不起作用 – Vinoth