httplistener

Starting multiple HTTP listeners on IIS using C#.NET 2.0

Hi, I have two windows services running on the same machine. Both the services uses private HttpListener listener; I specify the baseURL as "http://IPAddress:8080/" & "http://IPAddress:8081/" respectively for each of the services. Then I do the needful and call listener.Start(); The first service starts successfully at 8080 port. Bu...

How can I create an HttpListener class on a random port in C#?

I would like to create an application that serves web pages internally and can be run in multiple instances on the same machine. To do so, I would like to create an HttpListener that listens on a port that is: 1) Randomly selected 2) Currently unused Essentially, what I would like is something like: mListener = new HttpListener(); mL...

Custom URI for HTTPListener?

Is there a way to add a custom prefix/URI that is not http or https? The HTTPListener.Prefixes.Add method only accepts http:// and https:// prefixes. I just don't want to recreate the functionality of this class if I don't have to. ...

Alternative to HttpListener?

Hello, I'm developing an application that is so far using HttpListener to provide a small standalone http server. However, I've recently discovered that HttpListener needs to be run as Administrator, which is not always going to be possible. What would the best alternative be? I need http GET and POST, both of which are not simply read...

HttpListener Server Header c#

I am trying to write a C# http server for a personal project, i am wondering how i can change the returned server header from Microsoft-HTTPAPI/2.0, to something else? public class HttpWebServer { private HttpListener Listener; public void Start() { Listener = new HttpListener(); Lis...

"Specified network name is no longer available" in Httplistener

I have built a simple web service that simply uses HttpListener to receive and send requests. Occasionally, the service fails with "Specified network name is no longer available". It appears to be thrown when I write to the output buffer of the HttpListenerResponse. Here is the error: ListenerCallback() Error: The specified networ...

HTTP Proxy server in C#

My company is experimenting with writing a proxy server using the .NET Fx 3.5 and C#. From our research I have read that HttpListener is not a good candidate for a proxy server though I am unsure as to why. We are currently working with the Mentalis proxy example source code though that will involve, among other things, implementing ou...

How to flush HttpListener response stream?

HttpListener gives you response stream, but calling flush means nothing (and from sources it's clear, because it's actually doing nothing). Digging inside HTTP API shows that this is a limitation of HttpListener itself. Anyone knows exactly how to flush response stream of HttpListener (may be with reflection or additional P/Invokes)? U...

Easiest way to decode basic authorization in .NET

I need to validate a basic authorization header that is being sent to my HttpListener in VB.NET. I'm grabbing the header like so (feel free to point out better ways to do this as well): EncodedAuth = Context.Request.Headers.GetValues("Authorization")(1) Now how do I decode them? I understand the theory but I can't seem to find the r...

HttpListener: how to get http user and password ?

Hi, I'm facing a problem here, with HttpListener. When a request of the form http://user:[email protected]/ is made, how can I get the user and password ? HttpWebRequest has a Credentials property, but HttpListenerRequest doesn't have it, and I didn't find the username in any property of it. Thanks for the help. ...

Use HttpListener for a production caliber web server?

Is it realistic to use the C# .Net class HttpListener as the foundation for a production caliber web server? The http web service I need to host contains no .aspx or static files. All http responses are dynamic and generated in c# code that is invoked via a few switch statements which inspect a restful url format. My thinking is that I...

How can I get form parameters from HttpListenerRequest?

Hi, I am using a HttpListener to implement a very simple http server, which is accepting a POST from a Java client. When the client calls I get a HttpListenerRequest, which contains all the form parameters. How can I extract the form parameters? I seem to have access only to the content stream.... ...

Detect client disconnect with HttpListener

Hi, I have an application that uses HttpListener, I need to know when the client disconnected, right now I have all my code inside a try/catch block which is pretty ugly and not a good practice. How can I know if a client disconnected? thanks! ...

Compile an ASP.Net in a WinForms application

I'm trying to develop an agent/client that will listen to HTTP requests on a given port, and serve a simple ASP.Net page. To that end, I'm using the HttpListener and ApplicationHost classes. I've added a simple page to my project (mypage.aspx). When it contained all the code in the single file, all worked well (tested it by adding <% Res...

Why System.Net.HttpListener creates a new process?

Why the HttpListener class creates a new web server process, instead of use the normal Socket and a HTTP implementation? ...

How to set realm for Basic Authentication Scheme in .Net HTTPListener Google Chrome issue

I'm working with an HttpListener. I can set the Authentication mode to basic using: listener.AuthenticationScheme = AuthenticationSchemes.Basic; This works in IE, but Google Chrome doesn't seem to like empty realms. So the header should contain something like: WWW-Authenticate: Basic realm="The Byte that Overflew the Stack" However, ...

Raise event from http listener (Async listener handler)

Hello, I have created an simple web server, leveraging .NET HttpListener class. I am using ThreadPool.QueueUserWorkItem() to spawn a thread to listen to incoming requests. Threaded method uses HttpListener.BeginGetContext(callback, listener), and in callback method I resume with HttpListener.EndGetContext() as well as raise an even to no...

Self-Hosting WCF with Self-Hosting WebServer (HTTPListener) on the same port. Possible?

Hi, I'm working on an app and I need to provide a web interface to it. I was thinking about using WCF to provide a service for the web interface, and self-host both with my app (no IIS). Now, if those two are not using the same port, the browser will complain about XSS... Is this possible? Is this a good idea? EDIT After some investig...

c# HttpListener behind router

I have a web sever embebed in an application, very similar to this. But i have problems with i try access behind a router. I think code is right because if i change host file, all is working. Can anybody explain what is the problem? ...

httplistener doesn't work on port 80?

The setting: Windows 7, IIS installed and running. The following piece of code: HttpListener listener = new HttpListener(); listener.Prefixes.Add("http://server.com:8080/path"); listener.Start(); Works like charm - any request made against the server is received in my code. However, when I make the following change (moving to port 8...