Project

General

Profile

URL gets longer and longer

Added by Dave Soane over 5 years ago

Hi All,

I have one issue with my website that is causing some problems. Can anyone point me to the solution?

I use query strings with essay and poll numbers to navigate around the site. The problem is that the query strings simply get longer and longer. It doesn't happen if I use ugly URL's. I must admit I still haven't really got a handle on the whole internal path/pretty URL thing, so it's quite possible I am doing something wrong.

I have made the most basic program that I could, that reproduces the problem. After 5 cycles going between the Home page and "Page 1", the URL is:

http://localhost:8080/?num=1?num=1?num=1?num=1?num=1

Could someone tell me exactly what I need to do to the program, or its arguments, to stop it happening? Other than going back to ugly URL's. Thanks.

Arguments are : ---http-address=0.0.0.0 ---http-port=8080 ---deploy-path=/ ---docroot=".;/resources"

Program is:

#include "stdafx.h"

#include

#include

#include

#include

#include

using namespace Wt;

class SessionClass : public WApplication

{

public:

SessionClass(const WEnvironment &env): WApplication(env) {

internalPathChanged().connect(this, &SessionClass::handlePathChange);

show_page(0);

}

void handlePathChange();

void show_page(int which);

};

void SessionClass::show_page(int which)

{

root()->clear();

if (which == 0) {

root()->addWidget(new WAnchor(WLink(WLink::InternalPath, "/pages?num=1"), "This is Home. Click for Page 1"));

} else {

root()->addWidget(new WAnchor(WLink(WLink::InternalPath, "/"), "This is Page 1. Click for Home"));

}

}

void SessionClass::handlePathChange()

{

if (internalPath() \"/\") {
show_page(0);
}
if (internalPath() "/pages?num=1") {

show_page(1);

}

}

WApplication *createApplication(const WEnvironment& env)

{

return new SessionClass(env);

}

int main(int argc, char **argv)

{

return WRun(argc, argv, &createApplication);

}


Replies (1)

RE: URL gets longer and longer - Added by Dave Soane over 5 years ago

Seems that the optimiser here not only removes spaces and tabs at the beginning of lines, but also thinks that "==" is an error and removes it!

Which it did with

if (internalPath() '\' \"/\")

and
if (internalPath() \'' "/pages?num=1")

I had to put it in single quotes to get it to show!

    (1-1/1)