Reputation: 165
I have a C# form application which I want to have listening for incoming HTTP requests from other computers.
How would I go about doing this?
Upvotes: 15
Views: 23617
Reputation: 27011
If it's an asp.net application, you can check the http requests in the Application_BeginRequest event handler of your global.asax.
Upvotes: 0
Reputation: 1705
You can use ASP.NET Http Filters to intercept HTTP requests.
See more details here
Upvotes: 0
Reputation: 164281
For simple needs, the HttpListener
class is a good and simple choice. There is an example on the linked MSDN page.
If, for some reason, you cannot use HttpListener
, the process would be to listen to a port using TcpClient
(or even the sockets API if you need the gritty details), and then implement the HTTP Protocol. I highly recommend HttpListener
over rolling your own, unless you have specific requirements that HttpListener
does not meet.
Upvotes: 20