HttpListener Access Denied

S Abijith 466 Reputation points
2023-07-26T10:37:33.8166667+00:00

Hi All,

I am writing an HTTPs server in C# in .Net Framework 4.7.

When I try to execute the function HttpListener.Start(), I get an HttpListenerException saying

"Access Denied"

Can I make it run without admin mode? if yes how? If not how can I make the app change to admin mode after start running?

I have attached the code for reference!! HttpsListenerIssue.txt

Thank you in advance!!

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,279 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 86,966 Reputation points
    2023-07-26T10:50:05.89+00:00

    Nearly exactly the same question with same words as this question 13 years old...

    https://stackoverflow.com/questions/4019466/httplistener-access-denied


  2. Jiale Xue - MSFT 48,861 Reputation points Microsoft Vendor
    2023-07-28T09:00:57.33+00:00

    Hi @S Abijith , Welcome to Microsoft Q&A.

    Note:

    If you create an HttpListener using https, you must select a Server Certificate for that listener. Otherwise, requests to this HttpListener will fail with an unexpected close of the connection.

    See what the official documentation above says, you need to provide a certificate for your request.

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.