KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a class that needs to check the Authentication Mode from a web.config. Ex: <authentication mode="Forms" /> or <authentication mode="Windows" /> Now, I know this can be done pretty easily with the following code: AuthenticationSection sec = ConfigurationManager.GetSection("system.web/authentication"); if (sec.Mode == "Windows") { ... } My problem is, this class/project is being referenced in my Web project, as well as a WinForms project. The WinForms project is requiring .NET 4.0 Client Profile Framework (we don't want to require the full .NET 4 Framework, if possible). If I'm not mistaken, the Client Profile does not contain System.Web.dll. Is there a way that this value can be checked without referencing System.Web (and preferably without manually parsing the config file)? I've tried: object authSection = ConfigurationManager.GetSection("system.web/authentication"); if (authSection.ToString() == "Windows") { ... } However the ToString() simply returns the string "System.Web.Configuration.AuthenticationSection". Thank you!
Tags (comma-separated)
Save Edits
Cancel