Web Connection
URL Address
Gravatar is a globally recognized avatar based on your email address. URL Address
  Rod
  All
  Sep 24, 2019 @ 09:27am

Hi Rick et. all,

I use the the WWC base classes and a basic process class to generate pages. Often, on post back, my VFP function will then call another VFP function that subsequently renders a new page. I then end up with the script map URL reference of the calling function in the URL address bar, not the current page (script) address.

Can I rewrite the URL in the address bar to reflect the current page? Or maybe I'm doing something structurally wrong... I noticed this today when pressing an F5 page refresh and the calling function was missing something it needed, but really I would have rather just re-loaded the current page and executed the respective function (with parameters).

I was looking at UrlRewrite in the docs, which looks interesting and might make the URLs cleaner in general. But perhaps there's a way to change the URL address using your classes?

Thanks, Rod

Gravatar is a globally recognized avatar based on your email address. re: URL Address
  Rick Strahl
  Rod
  Sep 24, 2019 @ 11:04am

You cannot 're-write' the URL that is displayed on the title bar, that's determined by actual browser navigation. Once a page has been navigated that URL can't change. Client side code can modify the url based on the history API but even that involves an in page navigation.

I think what you want is to make sure you always have an explicit URL you are navigating to in your href and form action links or you want the server to 'redirect' to a new page which also causes the browser and address bar to reload.

I think the problem you have likely is that you're posting back to the same page with form action="" which always posts back to the same URL that you were on. Once you're done (say after a save) that URL is probably not what you want. So at the end of that request after a save operation you do:

if (oCustomer.Save())
   Response.Redirect("/customerlist.cust")
   RETURN
endif

*** otherwise re-render current page with error messages

Alternately you can also modify headers with a refresh header that shows the 'save message' and then redirects after a few seconds:

IF loCust.Save()
   Response.AppendHeader("Refresh","2;url=customerlist.cust")  && show result page then reload cust list after 2 secs
ENDIF

+++ Rick ---

© 1996-2019