Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get HTTPModule's own parameters in web.config?

I'm creating an HTTPModule which can be reused a few times, but with different parameters. Think as an example, a request redirector module. I could use an HTTPHandler but it is not a task for it because my process needs to work at the request level, not at an extension/path level.

Anyways, I'd like to have my web.config this way:

<system.webServer>
    <modules>
        <add name="tpl01" type="TemplateModule" arg1="~/" arg2="500" />    
        <add name="tpl02" type="TemplateModule" arg1="~/" arg2="100" />    
    </modules>
</system.webServer>

But most information I could find was this. I say, yeah, I can obtain the whole <modules> tag, but how do each instance of my HTTPModule knows which arguments to take? If I could get the name (tpl01 or tpl02) upon creation, I could look its arguments up by name afterwards, but I did not see any property in the HTTPModule class to get that.

Any help would be really welcome. Thanks in advance! :)

like image 412
DARKGuy Avatar asked Nov 21 '22 07:11

DARKGuy


1 Answers

I think, this part of config (system.webServer\modules\add ) is not intended to pass(store) parameters to modules, but to register list of modules to process request.

For possible atttributes in "add" element see - https://msdn.microsoft.com/en-us/library/ms690693(v=vs.90).aspx

like image 175
Timur Mannapov Avatar answered Nov 23 '22 20:11

Timur Mannapov