c# - How to check Authentication Mode value in Web.Config without referencing System.Web -


i have class needs check authentication mode web.config.

ex:

<authentication mode="forms" /> 

or

<authentication mode="windows" /> 

now, know can done pretty following code:

authenticationsection sec = configurationmanager.getsection("system.web/authentication"); if (sec.mode == "windows") { ... } 

my problem is, class/project being referenced in web project, winforms project. winforms project requiring .net 4.0 client profile framework (we don't want require full .net 4 framework, if possible). if i'm not mistaken, client profile not contain system.web.dll.

is there way value can checked without referencing system.web (and preferably without manually parsing config file)?

i've tried:

object authsection = configurationmanager.getsection("system.web/authentication"); if (authsection.tostring() == "windows") { ... } 

however tostring() returns string "system.web.configuration.authenticationsection".

thank you!

i have used above code authentication mode. done few changes in code. please find here.

authenticationsection authsection = (authenticationsection)configurationmanager.getsection("system.web/authentication");  if (authsection.mode.tostring() == "windows")   

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -