Re: Programatically change authentication mode at startup of web app?
- From: Dominick Baier <dbaier@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 13 Jul 2006 21:55:11 +0000 (UTC)
Hi,
ok - thats a strange requirement :))
programmatically changing the config works -
be sure to get a Configuration object
Configuration c = WebConfigurationManager.OpenWebConfguration("~");
then use GetSection to get ahold of the authentication section - it is important to call Save() on the Configuration object when you are done. Be prepared that your app will immediately recycle again after a config change.
But maybe you should come up with a scheme that supports both without having to change web.config....
Is there any way to change the authentication mode of a web app during
startup, say in the globl.asax.cs file? (if you are using c# of
course).
I have a situation where in some cases I need to use forms
authentication and sometimes I need windows authentication. They both
work fine stand-alone with static web.config files, but I need to make
the decision programatically based on external factors. Is this
possible?
I've already tried trapping the Application.Start event in
global.asax.cs and mucking with the properties of the
AuthenticationSection and AuthorizationSection objects that are loaded
from web.config, but even though they can be changed at runtime there
seems to be no effect.
Mike
.
- Follow-Ups:
- Re: Programatically change authentication mode at startup of web app?
- From: compurhythms
- Re: Programatically change authentication mode at startup of web app?
- References:
- Programatically change authentication mode at startup of web app?
- From: compurhythms
- Programatically change authentication mode at startup of web app?
- Prev by Date: Programatically change authentication mode at startup of web app?
- Next by Date: Re: forms authentication redirect problem
- Previous by thread: Programatically change authentication mode at startup of web app?
- Next by thread: Re: Programatically change authentication mode at startup of web app?
- Index(es):