nonstandard outgoing port with httpwebrequest

  • Thread starter Thread starter cd
  • Start date Start date
C

cd

ok, i,ve all but decided that this isn't going to be possible without a bit
of work, but i thought i'd post here as one last shot. the problem is that
i need to send http and https requests on nonstandard ports for some
internal firewalls, but i can't use the url domain:port syntax because the
web service im using kicks that back. i've used and love the
httpwebrequest class but it doesn't seem possible to change the destination
port with it without it also changing the url(UriBuilder). i'd hoped to
avoid writing my own tcpclient code to do this since everything but the
port is normal stuff.

tia
cd
 
Hi Chris,

I did not understand your meaning very well, do you mean the code similar
as below did not work for you?
UriBuilder myUri = new
UriBuilder("http","www.contoso.com",8080,"index.htm","#top");
HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create(myUri.Uri);

If so, I think we have to handle the connection issue with TCPClient which
is more flexible. I know that TCPClient is somewhat complex, but based on
my research the HttpWebRequest does not have a property named port, becasue
it considered the Uri as a whole unit including the protocol,port,webserver
and path.

If I have any misunderstanding, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
thanks for responding...
i've tried to use the builder similarly to how you suggest, but no matter
how its built it always seems to include the port in the url
(http://someservice.contoso.com:8080) i need the communication to happen
to the firewall using 8080, but not include it in the request line
(http://someservice.contoso.com). i didn't hold much hope that it would
work, but i love the httpwebrequest so much otherwise, i was hoping. i
think i may fall back to the InternetOpen api since it seems it might
handle the headers and request syntax for me...im not sure bout that yet,
but it may be quicker than rolling the protocol myself. the really
frustrating thing about all this is that i couldn't inherit the uri and
make the formatting changes i needed because nothing is marked
virtual...i think i could have made it work if i could have overridden
things like the absoluteuri property. thanks again, and if you have any
ideas to speed this project up, i would be extremely grateful. ive
overpromised a bit assuming i would be able to do this with
httpwebrequest :)



cd





(e-mail address removed) ("Peter Huang") wrote in
 
Hi

Based on my research I think we have no other method to change the port
property besides defined it in the url.
For now, I think we may try to take a look to see if we can change the web
server setting so that it can not get the request we post using
HttpWebrequest using url:port format.

If you still have any concern ,please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top