NetTalk Central

Author Topic: NetwebPage with redirect  (Read 3360 times)

MikeR

  • Sr. Member
  • ****
  • Posts: 257
    • View Profile
    • Email
NetwebPage with redirect
« on: March 08, 2019, 10:14:09 PM »
I am trying to redirect a request that comes into myserver to another server.
ie. I have created a netwebpage called red
so when a request comes in to www.myurl/red......
I do a p_web.redirect(www.anotherUrl) at the top of my code in the red netwebpage procedure...
I have also tried p_web.windowopen
Im not sure if this is correct or if its possible to do what I am trying in nettalk.

Jane

  • Sr. Member
  • ****
  • Posts: 354
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: NetwebPage with redirect
« Reply #1 on: March 09, 2019, 10:01:30 AM »
I did something that may be similar to this some years ago.

It's a "bounce" server with an XML configuration file (cached in an in-memory file) mapping friendly names to actual URLs.

So for example, somebody on our internal network can request http://ignite and winds up connecting to    
https://sys-app-ignite1.ournet.local:8124

I started by carving on Bruce's ErrorPage example (simple server with a non-existent Default Page).

I modified the p_web.CreateHeader in the WebHandler procedure so that it looks to match the requested URL to something in its redirection file.
  • if it finds a match
    • constructs the new URL and optionally appends the original request's parameters (if any)
    • constructs a 302 Redirect header to the new URL
    • returns
  • otherwise it does the parent.CreateHeader and lets the normal error-handling work.
   
It has an "admin" webpage to edit the redirection file.

Our internal DNS lists the bounce server's IP as the address for all the nicknames it will be redirecting.

This has been running as a service on our network for the past 4 years.  Prior to that, I had actually used a dedicated instance of IIS to do the redirections.

p_web.redirect maybe would have been a better approach, but this was the route I took.

Jane
 


MikeR

  • Sr. Member
  • ****
  • Posts: 257
    • View Profile
    • Email
Re: NetwebPage with redirect
« Reply #2 on: March 09, 2019, 10:10:06 AM »
Thanks Jane
can you expand on this for me:
constructs a 302 Redirect header to the new URL

Jane

  • Sr. Member
  • ****
  • Posts: 354
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: NetwebPage with redirect
« Reply #3 on: March 09, 2019, 10:47:13 AM »
Mike,

I stole the idea from my previous experience using IIS to do the redirections, which had been a handy trick I had used for years.  Older versions of IIS had an "HTTP Redirect" icon, which wound up replying to the caller with a 302 error pointing them at the desired server/page/port.  (I think that has been replaced by URL Rewrite in current versions).

Screen shot shows making a request to my app.  I'm using the same trick of replying with a 302 and the URL to which the caller should be sent.