c# - Creating custom ActionFilterAttribute -
I created an ActionFilterAttribute named LayoutAttribute and added it to ActionResult:
Controller: <<> Layout Attribution: System.Web.Mvc using } The problem is that OnActionExecuting is never called. I also tried to register the attribute in global.asax.cs, but then I needed a parametted constructor. I made it and added it to the global form. Ajax.cs like this: It's without any luck. What am I doing wrong? Be sure that you are implementing and not on both of them On Action Exposing and On Action-Detected Methods, So It May Be a little Fraudent [layout (pagetype department, "DNR")] Public Action Resolve KD (String Main Body, Int DNR) {<<>
; Using Komplett.Infrastructure.NInject; Using Ninject; Namespace Minion.Services.PageState {Public Category Layout Attribute: ActionFilterAttribute {Private Readonly PageTip _pageType; Private Redoni String _pageIdName; Public Layout Attribute (PageTipPageType, String PageIdname = "") {_pageType = PageType; _pageIdName = PageIdName; } Public Override Zero Onnection Acquisition (Action Accepting Contact Filter Context) {var page temmodel = kernelcontenter.color.gate & lt; PageStateModel & gt; (); If (filterContext.ActionParameters.ContainsKey (_pageIdName ?? "")) {pageStateModel.PageId = (string) filterContext.ActionParameters [_pageIdName]; } PageStateModel.PageType = _pageType; }}
GlobalFilters.Filters.Add (new layout attribute ());
System.Web .mvc.ActionFilterAttribute
System.Web.Http.Filters.ActionFilterAttribute
Comments
Post a Comment