I have a third party custom authentication HTTP module. I would like this module to configured to particular action method of a controller. Is this possible?
I know we can configure at folder level by having appropriate web.config at folder level, but I am looking for particular action method of particular controller.
You can’t enable a Http module to a particular controller, but you can enable it to a particular request path in web.config. That effectively does the job imo. The following web.config snippet enables “ThirdParty.HttpModule” only for request that match the “yourController” path. This should work with MVC, WebForms, and generic handlers as well.
The
inheritInChildApplicationspart is important, if you have any other applications in subdirectories of this application, because child applications would inherit this configuration by default, and you may not want this module to work in child applications.More info on MSDN.