473,651 Members | 2,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Relay Pages: Incoming to old IIS URL -> Request to new PHP Server for content -> Out to client

Hello,

note: This is for a Faculty web site that is undergoing a migration to
an open source solution so my motives are legit.

I need to build a relay from IIS handling URL_A to a PHP server
(URL_B), get the content from the PHP server (if it exists) and then
serve it out via IIS. If the content does not exist then I need to
pass the request through to the IIS server and serve the pages from
there. All of this needs to be done while retaining the existing URL_A
on the client side as we do not want to lose/change the url.

The steps I am thinking to accomplish this wonderful hack are:

1.) Trap requests to URL from IIS in a HttpModule

2.) Send a request from the HttpModule to PHP server for page content

3.) If page content is returned from PHP server then serve it out from
IIS (first changing any URL_B links to URL_A so that end user does not
see the temporary url being used by the PHP server and the IIS server
will still trap requests)

4.) If page content is not returned from PHP then pass through request
on IIS server and let it handle it.

I have had limited success trying the following classes:

HttpWebRequest,
HttpWebResponse and
HttpContext.Cur rent.Response.O utputStream.Wri te.

Unfortunately, after testing my code successfully on one part of the
new web site and I am now getting -1 returned at the end of the
following code:

HttpWebResponse myHttpWebRespon se=
(HttpWebRespons e)myRequest.Get Response();
Stream streamResponse= myHttpWebRespon se.GetResponseS tream()
(int)myHttpWebR esponse.Content Length

Everything else in myHttpWebRespon se looks to be fine and dandy.

It looks like I may have more success with:

WebClient.Downl oadFile

What implications will I have with PostBacks and what if anything do I
need to do to forward/return headers?

Does anyone have experience with doing something like this and if so
could I get some pointers/heads up?

Is there a name to what I am trying to do that will help me find some
info on the internet?

Thanx in advance

Jim

Dec 4 '06 #1
7 2769
Jim,

Let me make a few suggestions. I created a project which does url
mapping for ASP.NET using an HTTP module. It is also implemented with
as a provider, so you can change how the mappings are handled by
creating your own custom implementation. It handles much of the
trouble you come across when doing url mapping. You can get the full
source here.

http://svn.offwhite.net/svn/SmallSha...lMapper/trunk/

If you just want to look at some working code, you can see the module
here.

http://svn.offwhite.net/svn/SmallSha...apperModule.cs

The default provider is a static 1 to 1 mapping which takes a
configured path and maps it to a single endpoint, like
/mappedEndpoint/*.aspx to /masterTemplate. aspx. If you were to map
multiple endpoints to ASPX pages you could have those pages load
content from the PHP pages, perhaps caching the content whenever you
can to enhance performance. (see System.Web.Cach ing) Note that with
IIS you need the .aspx extention to have the .NET runtime handle the
request. Otherwise the HTTP module will not be reached. With IIS 6
you can configure different extensions to be handled by the .NET
runtime.

More here on IIS and .aspx extensions:
http://www.zorched.net/2006/01/20/as...spx-extension/

I do not know enough about your requirements to know if this is the
right approach though. Instead what you may want to do is redirect the
pages to the new locations. I run both IIS and Apache websites and
host my blog on an Apache server. I was running MovableType for my
blog but eventually moved to WordPress. I moved to WordPress because
it named the blog entries by the title of the page, I needed a way to
map requests to the old locations to the new one. I think this is what
you are looking to do.

To do it I used features within Apache to handle the redirects. My old
blog was moved to /mtblog/ while my new blog stayed at /blog/.

First I mapped MovableType urls in /blog/ to the new WordPress urls
with the RedirectMatch to do the a clean move from /blog/ to /mtblog/.

RedirectMatch atom.xml$ http://brennan.offwhite.net/blog/atom/
RedirectMatch index.xml$ http://brennan.offwhite.net/blog/feed/
RedirectMatch archives.html$
http://brennan.offwhite.net/mtblog/archives.html
RedirectMatch archives/(.*)$
http://brennan.offwhit e.net/mtblog/archives/$1

It just happened that MovableType generated static pages which I was
able to move over the the mtblog directory. But for the more popular
urls I wanted them to get back to the WordPress pages which had an
updated theme. So I added a url specific mapping to redirect them over
to the WordPress pages.

Redirect /mtblog/archives/000303.html
http://brennan.offwhite.net/blog/200...th-javascript/

In your case you would be mapping .aspx pages to .php so the
RedirectMatch directive will come in handy. To do this without
redirecting visitors to the new page (hiding the .php pages) you could
instead use a Url Rewriting feature. Look into the Apache module
mod_rewrite. You can have it magically accept the old url but
internally map it to a different internal url just like I do with the
UrlMapper project I listed above.

Brennan Stehling
http://brennan.offwhite.net/blog/
ASP.NET JAD (Just Another Developer)
Electric Co. wrote:
Hello,

note: This is for a Faculty web site that is undergoing a migration to
an open source solution so my motives are legit.

I need to build a relay from IIS handling URL_A to a PHP server
(URL_B), get the content from the PHP server (if it exists) and then
serve it out via IIS. If the content does not exist then I need to
pass the request through to the IIS server and serve the pages from
there. All of this needs to be done while retaining the existing URL_A
on the client side as we do not want to lose/change the url.

The steps I am thinking to accomplish this wonderful hack are:

1.) Trap requests to URL from IIS in a HttpModule

2.) Send a request from the HttpModule to PHP server for page content

3.) If page content is returned from PHP server then serve it out from
IIS (first changing any URL_B links to URL_A so that end user does not
see the temporary url being used by the PHP server and the IIS server
will still trap requests)

4.) If page content is not returned from PHP then pass through request
on IIS server and let it handle it.

I have had limited success trying the following classes:

HttpWebRequest,
HttpWebResponse and
HttpContext.Cur rent.Response.O utputStream.Wri te.

Unfortunately, after testing my code successfully on one part of the
new web site and I am now getting -1 returned at the end of the
following code:

HttpWebResponse myHttpWebRespon se=
(HttpWebRespons e)myRequest.Get Response();
Stream streamResponse= myHttpWebRespon se.GetResponseS tream()
(int)myHttpWebR esponse.Content Length

Everything else in myHttpWebRespon se looks to be fine and dandy.

It looks like I may have more success with:

WebClient.Downl oadFile

What implications will I have with PostBacks and what if anything do I
need to do to forward/return headers?

Does anyone have experience with doing something like this and if so
could I get some pointers/heads up?

Is there a name to what I am trying to do that will help me find some
info on the internet?

Thanx in advance

Jim
Dec 5 '06 #2
Thanx Brennan,

Quick question, what exactly fires the

PostMapRequestH andler.

I can find much information on this handler.

Jim

Dec 6 '06 #3
Further to my original post.

The name for what I am trying to do is "Reverse Proxy"

Lots of resources on the internet using this as a search term.

Jim

Dec 6 '06 #4
Look for the ASP.NET lifecycle. You will find a full list of the
events that fire.

For the UrlMapper I had to place those events at just the right stage
in the cycle.

Brennan Stehling
http://brennan.offwhite.net/blog/
Electric Co. wrote:
Thanx Brennan,

Quick question, what exactly fires the

PostMapRequestH andler.

I can find much information on this handler.

Jim
Dec 6 '06 #5
I created a reverse proxy system with Apache using mod_perl a long time
ago. Perhaps you could use the Apache 2 features for proxying as they
are not built-in and quite powerful.

Look over this page...

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

What I use to do with IIS6 was front the databases with an Apache 2
server set up as a reverse proxy with the gzip compression features on.
It was a great way to speed up the data transfer. With some fancy
reverse proxy and url rewriting you may be able to achieve what you
want. But combining those features together can be tough. They may
call that module chaining. I have not read up on all of the latest 2.2
features.

Brennan Stehling
http://brennan.offwhite.net/blog/

Electric Co. wrote:
Further to my original post.

The name for what I am trying to do is "Reverse Proxy"

Lots of resources on the internet using this as a search term.

Jim
Dec 6 '06 #6
typo...

now instead not built-in...
Brennan Stehling wrote:
I created a reverse proxy system with Apache using mod_perl a long time
ago. Perhaps you could use the Apache 2 features for proxying as they
are not built-in and quite powerful.

Look over this page...

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

What I use to do with IIS6 was front the databases with an Apache 2
server set up as a reverse proxy with the gzip compression features on.
It was a great way to speed up the data transfer. With some fancy
reverse proxy and url rewriting you may be able to achieve what you
want. But combining those features together can be tough. They may
call that module chaining. I have not read up on all of the latest 2.2
features.

Brennan Stehling
http://brennan.offwhite.net/blog/

Electric Co. wrote:
Further to my original post.

The name for what I am trying to do is "Reverse Proxy"

Lots of resources on the internet using this as a search term.

Jim
Dec 6 '06 #7
Thanx Brennan,

I am now looking at doing the Reverse Proxy on the Apache side.

Apache seems to be a little more friendlier then IIS. That said from
first glance it looks like you can get a bit more control with IIS - at
a price though.

Seeing as we are moving away from IIS and towards APACHE it does make
sense to go whole hog right from the start.

Thanks again.

Jim

Dec 7 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3931
by: Dicky Cheng | last post by:
Hi, I am using .net remoting technology. I set up a .net remoting client and server in IIS. When the client calls the server, the server will run a long duration method (30-60seconds). I have a test on it that if the network broken at the time the client have already send the remoting request and waiting for the server, the client side will wait infinitely by default, even if i already set the executionTimeout to 90seconds in...
7
5110
by: DW | last post by:
Hi, Here is my question. I want to push security prices to the desktop from the server. Whenever there is a new price in the database, the server notifies the client. How can this be done in the following situations using MS .NET Winforms on the desktop: 1. Using .NET Web Services on server 2. Using Java Web Services on server
2
1583
by: trint | last post by:
I have an app that uses the standard Socket Client code. I send it a message to call a function and it receives the message, debugs through the function, but the function doesn't actually fire. Anyone have a clue? Here is the code: public void DoRead(IAsyncResult ar) { int BytesRead; string strMessage;
14
6291
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2) show the error message next to the control. For example, if the text field is empty with RequiredField Validator control, it can show the value in ControlToValidate property in two ways as I mentioned. Please advise. Thanks!
3
2758
by: | last post by:
I have been researching articles on google on how to create a simple RSS feed that sucks <title><blurb><link><date> out of a sql server 2000 database via an aspx page. I know it has to be pushed into a <xml> document but not sure which direction to take. Is there perhaps a starter document which uses sql server as the data source I can tap into.
3
1693
by: Gerhard | last post by:
Is it possible to embed a .pdf file inside <asp:Content></asp:Content>? I have a page that has a master page with navigation, etc., and I want the content to be what is in a .pdf file. Is this possible? If so, how can I do it? Thanks.
2
2678
by: domtam | last post by:
Hi there. My goal is to write a windows service that can act as HTTP Request server. How can I do that? I know that I can use ASP.NET to develop a web site to achieve this purpose, i.e. receive HTTP request. However, I'd like it to exist in the form of a "Windows Service".
11
1201
by: K Viltersten | last post by:
In the client.js file i declare the following variable. ... var str = "info"; ... In the corresponding ASP file called server.aspx.cs i declare two following methods.
1
3788
by: tshad | last post by:
I have a W2K3 Server we are setting up to run a Windows Service for a client at their location. I don't want this machine to go through exchange or their local mail server, I just want the Server to send out a message from the SMTP Virtual Server to me (in a different company) to tell me that some exception has happened in our service. The problem is that it creates an error about a relay: Exception Type:...
0
8349
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8695
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8460
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8576
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6157
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4281
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
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 we have to send another system
1
1906
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.