-2

I am using a service for database communication using url with a smart hand held device. Here while going to httplistener.start() funcion I am getting an Acess denied exception. how to resolve this issue. here I have logged in as a normal user.My username =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();
        }
neo
  • 437
  • 7
  • 25

1 Answers1

0

When you listen on * you have to either be running as administrator or you have to have granted permissions to the account you are running as to listen on *.

There are several other posts on StackOverflow that discuss this already.

If you listen on http://localhost/[...] then you don't need to be an Administrator or have prvis granted to your account. Just keep in mind that you must load the pages with localhost in the URL not 127.0.0.1 as 127.0.0.1 will fail... it's not the same exact thing as making a request to localhost.

huntharo
  • 2,616
  • 21
  • 23