views:

26

answers:

2

I have a winform app and i would like to listen to a specific port and be able to visit the app through a browser. I know how to use HttpRequest and HttpResponse in asp.net project. But is there a way to use them in a winform app? or a variant of them? Currently i am using TcpListener and i need to write out my response and parse the request (i only need specific information, it was trivial). Whats the easiest way to communicate with HTTP in a winform app?

A: 

yes, you just have to add the following reference in your references.

System.Web
System.Net

winform does not add System.Web in its references but you can actually add this. I've done this a lot of times.

rob waminal
yeah but... with my tcplistener how do i get the request from the client to HttpRequest?
acidzombie24
are you getting the ip address of the http that you will be requesting from tcplistener or you already have the address to create an HttpRequest to? if you are getting the Ip from tcplistener you can use the `IPAddress` of the tcplistener from LocalEndPoint or RemoteEndPoint.
rob waminal
I still dont understand how i end up with a Http object? The ipaddress is fixed localhost with a user specified port.
acidzombie24
let me clarify, why are you using tcplistener? is this important? what is the url that you want to create an HttpRequest? Is the url that you want to make an HttpRequest come from tcplistener or you already have the url?
rob waminal
I am using tcplistener so i dont have to use sockets to get incoming connections. What i use isnt important. The url doesnt exist, i am hosting as a server so my browser or other apps can connect through mine with HTTP. I am not making an http request, i (http) response to other apps httprequest to my app.
acidzombie24
A: 

HttpListener

acidzombie24