Re: Proxy server with HttpListener



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..




Pro1712 wrote:
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
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

Pro1712 wrote:
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
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


Pro1712 wrote:
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
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

Pro1712 wrote:
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!

.



Relevant Pages

  • RE: HttpWebRequest over Https Via Proxy Fails using NTLM
    ... The proxy authentication header returns Basic, NTLM, and Negotiate. ... A network trace shows that the https request handshake is as follows: ...
    (microsoft.public.dotnet.framework.aspnet)
  • HttpWebRequest over Https Via Proxy Fails using NTLM
    ... proxy server on our internal network with 407 Proxy Authentication Required. ... The same request through the old proxy succeeds. ... Is there any way to debug the ntlm authentication module to see exactly what ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Proxy server with HttpListener
    ... Sadiq schrieb: ... I dont think there is any other open source proxy that is made in .NET. ... request to the internet. ... How can I send the HttpListenerRequest to the internet and put the ...
    (microsoft.public.dotnet.framework.webservices)
  • Webservices Basic Authentication Bottlenecks
    ... I am connecting a .NET serviceto a .NET WebService via a Squid ... Proxy running basic authentication. ... To make this work I have created a webproxy and set it to each request. ... When the request is made the proxy first fires back a 407 Proxy ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: bypassing proxy
    ... and when the proxy is removed he's able to ... Chances are that you need to enable authentication caching on the ISA ... Web-apps often request authentication for each request. ... BigFix ...
    (Security-Basics)