c# - Creating custom ActionFilterAttribute -


I created an ActionFilterAttribute named LayoutAttribute and added it to ActionResult:

Controller: <<> [layout (pagetype department, "DNR")] Public Action Resolve KD (String Main Body, Int DNR) {<<>

Layout Attribution: System.Web.Mvc using

 ; 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; }}   

}

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:

  GlobalFilters.Filters.Add (new layout attribute ());   

It's without any luck.

What am I doing wrong?

Be sure that you are implementing

  System.Web .mvc.ActionFilterAttribute   

and not

  System.Web.Http.Filters.ActionFilterAttribute   

on both of them On Action Exposing and On Action-Detected Methods, So It May Be a little Fraudent

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -