Tôi đang cố gắng để biến xác thực Anonymous trên một trang web sử dụng C#tôi không thể thiết lập IIS xác thực programatically sử dụng C#
Mã này ném ngoại lệ được viết ở phía dưới tôi đã tìm kiếm khắp mọi nơi tôi không thể tìm thấy câu trả lời làm thế nào để giải quyết nó:
using (ServerManager serverManager = new ServerManager())
{
Configuration configapp = serverManager.GetApplicationHostConfiguration();
ConfigurationSection anonymousAuthenticationSection = configapp.GetSection("system.webServer/security/authentication/anonymousAuthentication", Site1);
anonymousAuthenticationSection["enabled"] = false;
serverManager.CommitChanges();
}
Trường hợp ngoại lệ:
System.IO.FileNotFoundException: Filename: \\?\C:\Windows\system32\inetsrv\config\applicationHost.config
Error: Unrecognized configuration path 'MACHINE/WEBROOT/APPHOST/Site1'
at Microsoft.Web.Administration.Interop.AppHostWritableAdminManager.GetAdminSection(String bstrSectionName, String bstrSectionPath)
at Microsoft.Web.Administration.Configuration.GetSectionInternal(ConfigurationSection section, String sectionPath, String locationPath)
at Microsoft.Web.Administration.Configuration.GetSection(String sectionPath, String locationPath)
at FlowSuiteWebConfigurator.label.button1_Click(Object sender, EventArgs e) in C:\Users\Administrator\documents\visual studio 2010\Projects\Projectname\Projectname\Form1.cs:line 264
có thể ai đó hướng dẫn cho tôi làm thế nào để sửa lỗi này?
Thấy là bạn có C# được gắn thẻ, tôi đoán đây là ASP.NET. Nếu bạn muốn từ chối bất kỳ người dùng nào không được xác thực, bạn nên làm điều đó trong web.config của trang web thực sự của bạn. Điều này sẽ từ chối người dùng trái phép truy cập trang web của bạn. Authorization> –
seekerOfKnowledge
Tôi thực sự đang sử dụng C# dưới dạng biểu mẫu cấu hình web IIS. và tôi muốn đầu tiên vô hiệu hóa chương trình đăng nhập anon và sau đó chỉ áp dụng "xác thực cửa sổ" – user1593455