Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Guys,

Is there any way we can assign value of key to the property of handler in web.config ?

e.g

<add key="FileLocation" value="Log/test.html" />

<handlers>
<add name="XYZ" verb="POST,GET,HEAD" path="{FileLocation}" type="Test.App" />
</handlers>


Thanks in Advance.
Posted
Comments
Dave Kreskowiak 18-Jul-15 21:29pm    
Your question doesn't make any sense at all. One has nothing to do with the other.

What do you mean by "assign the value of key to the property of handler"? What property?
[no name] 19-Jul-15 2:34am    
Hi Dave, I think you didn't check the example properly.

I defined key filelocation in appsettings and want to use this value in the path property of handler XYZ.

Its like define a variable and use its value at multiple locations.

I think, now you understand the question, if not please let me know.

Cheers.

Dave Kreskowiak 19-Jul-15 9:44am    
Oh, I read it alright and I understand what each piece means. It was your explanation that was lacking in detail precisely what you wanted to do.
Kornfeld Eliyahu Peter 19-Jul-15 7:20am    
No!

1 solution

You cannot specify a variable-replaced path like that anywhere in the app.settings and expect it to work. There is no in-built support for it.
 
Share this answer
 
Comments
[no name] 19-Jul-15 10:31am    
Hi Dave,

Is there anyway, we can achieve this ?
Otherwise, it's a tedious task to maintain same value at different places.

Cheers,
Adi.
Dave Kreskowiak 19-Jul-15 11:52am    
The question is not "how to do this", but "why do you think you need to"?

What are you trying to accomplish with this?
[no name] 19-Jul-15 12:07pm    
Basically I am using elmah and i am applying custom authentication on elmah.axd file. When elmah handler is registered in web.config it has a path property in it. I want to set the value of this path property by the appsetting key.

That's why i need it.
Cheers,
Adi.
Dave Kreskowiak 19-Jul-15 17:12pm    
Using what?

The "elmah" I'm familiar with refers to any error error logging module. Why on earth would you put authentication on that? And why are you trying to change the path of the registered module.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900