Ich habe dieses seltsame Problem, wo ich reserve URL zu ACL-Liste hinzufügen (programmgesteuert so), aber wenn ein Programm ausgeführt wird, bekomme ich immer noch die Fehlermeldung "Zugriff verweigert".C# URL Reservierung Host-Problem
public void initRest() {
// Add ACL Service Exception
addACLServiceException();
/*
* initRest will lunch a separate thread that will be responsible for REST service
*/
new Thread(() =>
{
Thread.CurrentThread.IsBackground = true;
RestServicesImpl services = new RestServicesImpl();
WebHttpBinding binding = new WebHttpBinding();
WebHttpBehavior behavior = new WebHttpBehavior();
WebServiceHost _serviceHost = new WebServiceHost(services, new Uri("http://localhost:8000/RestService"));
_serviceHost.AddServiceEndpoint(typeof(RestServices), binding, "");
_serviceHost.Open();
Console.ReadKey();
_serviceHost.Close();
}).Start();
}
private void addACLServiceException() {
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/K netsh http add urlacl url = http://+:8000/RestService/ user=%USERNAME%";
startInfo.Verb = "runas";
process.StartInfo = startInfo;
process.Start();
}
Lauf netsh http show urlacl
von CMD-Fenstern (als admin) i, dass die reservierte URL sehen kann in der Tat ist, wo es
Reserved URL : http://+:8000/RestService/
User: DESKTOP-F8O3V2Q\Boss
Listen: Yes
Delegate: No
SDDL: D:(A;;GX;;;S-1-5-21-990234104-2306344669-2817477651-1001)