httplistener

HttpListner: intercept requests to WCF DataService

Hello, I want to use the .net class HttpListener to intercept requests to my selfhosted (WebServiceHost) WCF Data Service in order to add the "WWW-Authenticate" header to the response (for user authentication). But it seems like that the HttpListener doesn't intercept any requests that go to my dataservice. The HttpListner works for dif...

Can a WebServiceHost be changed to avoid the use of HttpListener?

I am looking for a way to use a WCF WebServiceHost without having to rely on the HttpListener class and it's associated permission problems (see this question for details). I'm working on a application which communicates locally with another (third-party) application via their REST API. At the moment we are using WCF as an embedded HT...

.NET HttpListener Prefix issue with anything other than localhost

I'm trying to use C# and HttpListener with a prefix of anything other than localhost and it fails (i.e. if I give it "server1", i.e. http://localhost:1234 works, but http://server1:1234 fails The code is... HttpListener listener = new HttpListener(); String prefix = @"http://server1:1234"; listener.Prefixes.Add(prefix); listener.St...

C# HttpListener without using netsh to register a URI

My application uses a small webserver to server up some files and have a web interface for administration remotely. Right now the user has to use netsh to register the URI like so netsh http add urlacl url=http://+:1233/ user=Chris-PC\Chris Which is no fun for the average user. I'd like the program to be able to listen on any port sp...

How to be sure a http request is local when using HttpListener

I'm using HttpListener. I want to only process requests however that come locally, not from another machine/server. How would I programmatically verify if an incoming request is local for sure? For example would it be using some of the HttpListenerRequest members? ...

HttpListener - how do I send a WebException HTTP 304 "Not Modified" error back to browser?

Hi, How do I mimic a WebException 304 error back to browser if I am using HttpListener? That is I have received a request to my HttpListener, and then obtained the HttpListenerContext, then from this point how would I mimic/arrange for a HTTP "304 Not Modified" response to be effectively sent back to the browser via the HttpListenerCon...

.NET HttpListener: when registering both HTTP & HTTPS I get "conflicts with an existing registration on the machine"

I'm trying to use .NET HttpListener in a C# project. When I register my prefix "http://*:8080/" it does not seem to work for HTTPS urls (i.e. doesn't pick them up). When I try the following code to register both the HTTP and HTTPS versions of the prefix however I get the error: "Failed to listen on prefix 'https://:8080/' because it c...

.NET - Is it possible to proxy a HTTPS request using HttpListener & HttpWebRequest? (or is it not possbile due to the encryption?)

Hi, Question - Is it possible to proxy a HTTPS request using HttpListener & HttpWebRequest? (or is it not possbile due to the encryption?) I have got a .NET proxy working by using HttpListener & HttpWebRequest using the approach here. I'm trying to extend this at the moment to listen for HTTPS too (refer this question) however I'm won...

.NET HttpListener - no traffic when listening to "https://*.8080" when browser proxy is set???

Hi, Background - I can get HttpListener working fine for HTTP traffic. I'm having trouble with HTTPS traffic however. QUESTION: How can I change the code below so that a browser request to a "https" URL will actually be picked up by my HttpListener? Notes - At the moment with firefox's proxy settings set to "localhost:8080", when ...

c# HTTPListener encoding issue

I have a Java application sending HTTP requests to a C# application. The C# app uses HTTPListener to listen for requests and respond. On the Java side I'm encoding the URL using UTF-8. When I send a \ character it gets encoded as %5C as expected but on the C# side it becomes a / character. The encoding for the request object is Windows...

Windows Service HTTPListener Memory Issue

Hi all, Im a complete novice to the "best practices" etc of writing in any code. I tend to just write it an if it works, why fix it. Well, this way of working is landing me in some hot water. I am writing a simple windows service to server a single webpage. (This service will be incorperated in to another project which monitors the ser...

How to parse a raw HTTP response?

If I have a raw HTTP response as a string: HTTP/1.1 200 OK Date: Tue, 11 May 2010 07:28:30 GMT Expires: -1 Cache-Control: private, max-age=0 Content-Type: text/html; charset=UTF-8 Server: gws X-XSS-Protection: 1; mode=block Connection: close <!doctype html><html>...</html> Is there an easy way I can parse it into an...

Does HttpListener work well on Mono?

Hi everyone. I'm looking to write a small web service to run on a small Linux box. I prefer to code in C#, so I'm looking to use Mono. I don't want the overhead of running a full web server or Mono's version of ASP.NET. I'm thinking of having a single process with a thread dealing with each client connection. Shared memory between threa...

Update a field from server without reloading the existing page using simple javascript.

I want to change a value of a field say document.getElementById('reloader').innerHTML = updated value from Server I do not want to use Ajax, PHP, ASP, JSP .. or anything like these. Is it possible by using simple javascript? Server is C# 's application made by using HttpListener. Please question if needed more info. ...

changing httplistener class url prefixes on the fly

Hi, I am using an Httplistener class for receiving incoming http and https requests. I changed the url prefixes on the fly i.e. I initially had setup http://+/link/ and https://+/link as the URL prefix. I then added https://+:8081/link/ as another prefix but received no response when i sent a request on this url. Am I doing something...

.NET HttpListener/HttpWebRequest/HttpWebResponse and HTTPS

I have made a simple proxy using HttpListener and HttpWebRequest/Response to edit and log http headers. Everything works fine and dandy over HTTP but HTTPS is a different story, I have read up on MSDN and its says HttpListener & HttpWebRequest/Response works over HTTPS. Obviously its me doing something wrong. I have IE pointed to the pr...

Http Listener doesn't work on Port 8080 or other ports (works only on port 80)

Hi, I wrote a simple WebServer using HttpListener class (.net 2.0) It seems that It doesn't work on port other then 80. When i sniff the transport to my server i can see the Syn packets on Port 8080 arrive to the server, but there is no Syn/Ack response, although when i sue netstat -a i can see that the server is listening to port 808...

HttpListener only gets first 900 bytes of InputStream when using jQuery.ajax()

I have a very simple class using HttpListener to receive an HTTP POST from a browser via an AJAX request. I've included a demo that highlights this issue: private static void HandleRequest(HttpListenerContext context) { using (var inputStream = context.Request.InputStream) { for (int i = 0; i < context.Request.ContentLen...

HttpListener Access Denied c# windows 7

I am writing an HTTP server in C#. When I try to execute the function HttpListener.Start() I get an HttpListenerException saying "Access Denied". When I run the app in admin mode in windows 7 it works fine. 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? thanks...