473,241 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

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.Current.Response.OutputStream.Write.

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 myHttpWebResponse=
(HttpWebResponse)myRequest.GetResponse();
Stream streamResponse=myHttpWebResponse.GetResponseStream ()
(int)myHttpWebResponse.ContentLength

Everything else in myHttpWebResponse looks to be fine and dandy.

It looks like I may have more success with:

WebClient.DownloadFile

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 2746
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.Caching) 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.offwhite.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.Current.Response.OutputStream.Write.

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 myHttpWebResponse=
(HttpWebResponse)myRequest.GetResponse();
Stream streamResponse=myHttpWebResponse.GetResponseStream ()
(int)myHttpWebResponse.ContentLength

Everything else in myHttpWebResponse looks to be fine and dandy.

It looks like I may have more success with:

WebClient.DownloadFile

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

PostMapRequestHandler.

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

PostMapRequestHandler.

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
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...
7
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...
2
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. ...
14
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)...
3
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...
3
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...
2
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....
11
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
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...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.