Read Authentication Type From Web.Config

H

hilary321

Hi-

I am using ASP.NET 2.0. I would like to have a generic function in my
application that will determine what type of authentication to use and
then proceed with authentication, either Windows or Forms.

How do I read the authentication type from Web.Config?

Thanks in advance,

Renae
(e-mail address removed)
 
G

Guest

You are defining the type in the web.config... so checking from there seems
kind of a waste.... or am I missing something?
 
R

Renae

I have a page object that I'm including the code to perform the Windows
authentication. If the authentication mode is set to forms in the
web.config, I don't want to execute this code. I would like the page
object to be able to be used for either authentication mode. Something
like this maybe:

if (authentication_mode == "Windows")
{
.....
}

Is there a way to tell in the application what kind of authentication
was used?

Thanks,
Renae
 
B

Brock Allen

Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
SystemWebSectionGroup grp = (SystemWebSectionGroup)config.GetSectionGroup("system.web");
AuthenticationSection auth = grp.Authentication;
if (auth.Mode == AuthenticationMode.Forms)
{
}
else if (auth.Mode == AuthenticationMode.Windows)
{
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top