0

I need to set the Authentication model of a specific asp.net file in my IIS webservice application. Topic "How do I programmatically set Integrated Windows Authentication in IIS on a .NET web service?" basically does what I want, but for an entire site. I need to have all but one of my webservices anonymous access, but one needs to use "Windows Authentication"

Like So:

enter image description here

I cannot figure out how to specify a certain file when applying this code:

String applicationPath = String.Format("{0}/{1}", _server.Sites["Default Web Site"].Name, "AppName"); 

Configuration config = _server.GetApplicationHostConfiguration(); 

ConfigurationSection anonymousAuthenticationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", applicationPath); 

anonymousAuthenticationSection["enabled"] = false; 

ConfigurationSection windowsAuthenticationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", applicationPath); 

windowsAuthenticationSection["enabled"] = true; 

_server.CommitChanges(); 

1 Answer 1

0

you can use the location node of the web.config file to configure specific directories/files of the application. or if you don't want to clutter the root web.config you can create additional web.config files in the sub-directories.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.