on http侦听器的start()函数转到异常"访问被拒绝"

时间:2013-10-16 07:57:27

标签: .net c#-4.0 windows-7 windows-services httplistener

我正在使用带有智能手持设备的url进行数据库通信的服务。在这里访问httplistener.start()函数时,我得到一个Acess拒绝异常。如何解决这个问题。这里我以普通用户身份登录。我的用户名= NI-PC036,userdomain = User33。

      urlExecuter = new UrlExecuter();
                eventStop = new ManualResetEvent(false);


                MySql.Start();

                // HTTP
                httpListener = new HttpListener();
                httpListener.Prefixes.Add("http://*/");
                httpListener.Start();
                httpListener.BeginGetContext(new AsyncCallback(HttpListenerCallback), httpListener);
  httpListener.BeginGetContext(new AsyncCallback(HttpListenerCallback), httpListener);


            cleanupThread = new Thread(delegate()
            {
                while (!eventStop.WaitOne(5 * 60 * 1000))   // 5Min
                {
                    try
                    {
                        if (cleanupTime.AddDays(1) < DateTime.Now)
                        {
                            int days = MiscTool.ReadIni<int>("SERVICE", "KEEP", 60);
                            Cleanup.Execute(days);
                            cleanupTime = DateTime.Now.Date;
                        }
                    }
                    catch (Exception ex)
                    {
                        Program.WriteExceptionLog("cleanupThread", ex);
                    }
                }
            });
            cleanupThread.Start();
        }

1 个答案:

答案 0 :(得分:0)

当您收听*时,您必须以管理员身份运行,或者必须已授予您正在运行的帐户的权限,以便收听*。

StackOverflow上还有其他一些帖子已经讨论过这个问题。

如果您在http:// localhost / [...]上收听,则无需成为管理员或授予您的帐户prvis。请记住,您必须在URL不是127.0.0.1中使用localhost加载页面,因为127.0.0.1将失败...这与向localhost发出请求不同。

相关问题