Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / July 2006

Tip: Looking for answers? Try searching our database.

Proxy server with HttpListener

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pro1712 - 11 Jul 2006 13:13 GMT
Hello,

I need to write a simple proxy server.
What I want to do is to use HttpListener to get requests from the
browser, add some proxy information and some other stuff and send the
request to the internet.
Then I want to send the answer back to the browser...
Sounds simple...

But how can I do this?

Has anyone done this before? Is there an example?
I already tried to find something but I had no luck so far...
Alle samples I found so far show some really basic information, but
nothing that really helped me...

How can I send the HttpListenerRequest to the internet and put the
answer back in the HttpListenerResponse?

Thanks for your help!
Sadiq - 12 Jul 2006 12:01 GMT
I had tried this but i would not recommend to use it as HTTPListener
gives strange behaviour and you wont be able to get your proxy at work
completely. still if you wanna try your luck then, You can forward the
request got  from HTTPListenerRequest using HTTPWebRequest class and
get the response back from the web server using HTTPWebResponse class,
then you can write back this response to the HTTPListenerResponse
object.

After appx 2 months of work i wasnt able to solve some errors of
HTTPListener so then i changed my approach and shifted towards sockets.
For examples in .NET you can see the source code of Mentalis proxy at
http://www.mentalis.org/soft/projects/proxy/

Good luck

/Sadeeq

> Hello,
>
[quoted text clipped - 16 lines]
>
> Thanks for your help!
Pro1712 - 13 Jul 2006 09:23 GMT
Thanks for your answer!

I looked at the sample.
It's written for .NET 1.0. Did you update it for .NET 2.0?
It will not work for IPv6. But this is necessary for my project...

Do yout know any other samples?

Thanks!!!

Sadiq schrieb:

> I had tried this but i would not recommend to use it as HTTPListener
> gives strange behaviour and you wont be able to get your proxy at work
[quoted text clipped - 33 lines]
> >
> > Thanks for your help!
Sadiq - 13 Jul 2006 14:52 GMT
Hi,
Yes its written in .NET 1.0 but it doesnt require much modifications
for .NET 2.0 if you are only using it as HTTP Proxy, you need only few
classes in that case.  In my case yes i considerably changed them to
suit my needs and rewritten the classes in VB.NET and .NET 2.0 instead
of C#.
I am not sure whether it will work with IPV6 or not, you can check it.
The point is that you can get the basic idea and then write your own.
I dont think there is any other open source proxy that is made in .NET.
You can find many in Java or other languges.

Best Regards

/sadeeq

> Thanks for your answer!
>
[quoted text clipped - 45 lines]
> > >
> > > Thanks for your help!
Pro1712 - 18 Jul 2006 12:11 GMT
Hello,

how can I add authentification to the HttpClient?

How did you convert the function IPAddress.Address to .NET 2.0?

Can you help me?

Thanks for your help!

Sadiq schrieb:

> Hi,
> Yes its written in .NET 1.0 but it doesnt require much modifications
[quoted text clipped - 60 lines]
> > > >
> > > > Thanks for your help!
Sadiq - 20 Jul 2006 10:12 GMT
Hello,
Do you mean Authentication to the proxy? or to any website using the
proxy..
There are authentication classes in the proxy project like
"AuthenticaionList.cs", AuthBase.cs, AuthUserPass.cs etc...have a look
if it works for you. otherwise you have to write your own class for
authentication and call it before the HTTPClient class.

Use IPAddress.Parse. ( or IPAddress.Equals)

Regards,
Sadeeq

> Hello,
>
[quoted text clipped - 72 lines]
> > > > >
> > > > > Thanks for your help!
Pro1712 - 20 Jul 2006 12:03 GMT
Hi,

What I want to do is this:
My browser makes a request to the Proxy. The Proxy authenticates to the
company's proxy and sends the request to the company's proxy. This
proxy connects to the destination site and gets the pages.

The class HttpClient tries to connect directly to the destination. This
of course fails.
So my problem is to authenticate to the company's proxy and forward the
request and then receive the answer and send it back to the browser.
I have no idea how to do this...

Thanks!

Sadiq schrieb:

> Hello,
> Do you mean Authentication to the proxy? or to any website using the
[quoted text clipped - 85 lines]
> > > > > >
> > > > > > Thanks for your help!
Sadiq - 24 Jul 2006 14:54 GMT
hi,
well you have to modify the code. You can write your own authentication
class using sockets that will write the authentication details to your
company proxy..(obviously that would be running on some network port,
so you need to send and recieve data on that port using your socket in
your authenticaion class).

Now when you recieve first request in HTTPClient Class then instead of
forwarding it to the remote host directly, first you call your
authentication class using whatever credintials you provide, that class
will write the credentials to your company proxy and recieves the
response, once you get the resposne then you need to simply forward
that captured HTTP request to your company proxy. Instead of the remote
host address you need to initilize your remotehost in HTTPClient class
to the IP Address and port of your company proxy...rest it will handle
itself.....

hope this helps..

> Hi,
>
[quoted text clipped - 102 lines]
> > > > > > >
> > > > > > > Thanks for your help!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.