asp.net - How to register delegating handlers in a MVC Application? (not Web API) -


how register global message handler in mvc application?

i tried registering in global.asax.cs, handler never gets called whenever access of endpoints in controllers inherit system.web.mvc.controller.

however, does called when access routes controllers inherit system.web.http.apicontroller.

this put in global.asax.cs:

protected void application_start() {     //other initializing stuff here     **globalconfiguration.configuration.messagehandlers.add(new authenticationhandler());**  }    

i believe you're looking filters. build this:

public class myauthorizationfilter : iauthorizationfilter {     public void onauthorization(authorizationcontext filtercontext)     {         // work here     } } 

and add global filters list in application_start:

globalconfiguration.configuration.filters.add(new myauthorizationfilter()); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -