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. 1 2663
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" <ma******@gmail.comwrote in message
news:11**********************@w5g2000hsg.googlegro ups.com...
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Raymond Hettinger |
last post by:
Please comment on the new PEP for reverse iteration methods.
Basically, the idea looks like this:
for i in xrange(10).iter_backwards(): # 9,8,7,6,5,4,3,2,1,0
<do something with i>
The...
|
by: Mark Ferguson |
last post by:
I've been trying to get a simple pycurl script working with an
authenticating proxy, here is the code (with changes to protect the
guilty!):
from pycurl import *
import StringIO
b =...
|
by: JavaScriptRocks |
last post by:
I've been trying to imitate / reverse engineer the add attachment
feature in gmail composer. I managed to do it to say about 80% but its
giving me trouble in IE on WinXP-Sp2. I am using PHP to do...
|
by: A.M |
last post by:
Hi,
We are developing ADP.NET applications and one of our requirements is
implementing a Reverse Proxy on IIS.
I have couple of questions about Reverse Proxy:
|
by: =?Utf-8?B?a2NtYXJzaGFsbC5tc3A=?= |
last post by:
We're working on an app that will be integrated with another web app through
a reverse proxy. Our aspx pages will appear in an IFrame from their site and
will appear to the client browser as...
| |
by: etnaelk |
last post by:
Hi all, I have a real bugger of a problem that I just haven't been able to figure
out. I am working on writing my own proxy server in C# using TcpListener,
TcpClient, HttpWebRequest/Response and...
|
by: Jane Parker |
last post by:
I read with interest the recent posting about Reverse Proxies and wondered
if it is possible to mix static and dynamic content.
If you have a lot of static content on your site it would make...
|
by: kokababu |
last post by:
Hi,
I have setup a reverse proxy server which will route the request to
Server B. Proxy server is working well with Server B.
I would like to catch HTTP status error like 404/500 from server...
|
by: =?Utf-8?B?d2FsdGVy?= |
last post by:
Hi there... I am stuck here ,and wish you could help. We have a webservice
proxy, since we are moving to WCf , we will want to re-generate a new proxy.
The problem is we do not own the service and...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |