以下のコードを実行した際に管理者権限での実行を求められました。
ローカルホストを指定した際、以前は管理者権限は必要なかったように思います。
管理者権限がない状態でもlocalhostを指定してwebサーバーを立ち上げられますか?
宜しくお願いします。
using System; using System.IO; using System.Net; using System.Text; class Program { static void Main(string[] args) { try { HttpListener listener = new HttpListener(); listener.Prefixes.Add("http://localhost/"); listener.Start(); while (true) { HttpListenerContext context = listener.GetContext(); HttpListenerResponse res = context.Response; res.StatusCode = 200; byte[] content = Encoding.UTF8.GetBytes("HELLO"); res.OutputStream.Write(content, 0, content.Length); res.Close(); } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } } }

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。