Re: ASP.Net reverse proxy image problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I would recomend to intall fiddler.
http://www.fiddlertool.com/fiddler/

to see what your browser is getting back from your proxy.


George.


"Dave Mathew" <mathewda@xxxxxxxxx> wrote in message
news:1182375755.118369.158330@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm attempting to write a reverse proxy in ASP.Net which will catch
requests to my server in ASP.Net, perform some actions, and then get
the desired resource off another server to return to the original
client (using HttpWebRequest and rewriting it's response to my ASP.Net
client). I'm able to get the reverse proxy to work for html pages but
it's not working for images. Right now the code I'm playing with is
similar to this:

void context_BeginRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;
// Get image in another request
HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create("http://
otherserver.com/image.gif");

// Copy header variables
foreach (String each in app.Request.Headers)
{
if (!WebHeaderCollection.IsRestricted(each))
webreq.Headers.Add(each,
app.Request.Headers.Get(each));
}

// Get Response (the image) and write it's stream back to the
original client
HttpWebResponse response = (HttpWebResponse)webreq.GetResponse();
Stream responseStream = response.GetResponseStream();
Stream output = app.Response.OutputStream;
copyStream(responseStream, output);
}

When I debug the code seems to be getting the stream for the image ok
(if I do this in a windows forms app I can get an image from the
stream and show it in a picture box just fine), but the browser
apparently isn't receiving the response it expects because it either
gives an error or if the requested image is part of another page it
shows the familiar image not found icon. I've looked at a few other
reverse proxy's in ASP.Net and they don't seem to be doing anything
special for different types of files so I'm not sure what I'm doing
wrong here... any suggestion? I thought maybe having this code in the
BeginRequest event may be part of the problem, but it works for HTML
pages so that makes me think it's something else I'm overlooking. Any
help would be greatly appreciated.



.



Relevant Pages

  • Re: NotificationSampleWebDav-Monitor OWA Inbox
    ... re-login or update your cookie with each response you get... ... Warning: Exiting Action with an exception: The remote server returned an ... // Create request object and assign credentials. ... Stream newStream = Request.GetRequestStream; ...
    (microsoft.public.exchange.applications)
  • Re: Client Server
    ... Otherwise, read a file in via a stream, make any required updates, and write ... > myself and compares it to the data that the client has sent to ... My response, though it was very general in nature, assumed exactly what you ... at some point you want the server to read this file in. ...
    (comp.lang.java.help)
  • ASP.Net reverse proxy image problem
    ... I'm attempting to write a reverse proxy in ASP.Net which will catch ... requests to my server in ASP.Net, perform some actions, and then get ... client (using HttpWebRequest and rewriting it's response to my ASP.Net ... // Get Response and write it's stream back to the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: NotificationSampleWebDav-Monitor OWA Inbox
    ... Thank you for your quick response, seems I'm moving in the right direction.. ... Warning: Exiting Action with an exception: The remote server returned an ... Stream newStream = Request.GetRequestStream; ... // Throw a clean version of the internal server error. ...
    (microsoft.public.exchange.applications)
  • Apache/Tomcat Denial Of Service And Information Leakage Vulnerability
    ... mod_jk 1.2 using Apache Jserv Protocol 1.3 ... Tomcat 4.x Server ... A client may connect to the target machine and deliver several requests ... response back over the connection. ...
    (Bugtraq)