Question

I am unfamiliar with ASP but I need to link directly to a page on the http://carfueldata.direct.gov.uk/ website which I assume from the .aspx extension is built in it. My problem is that when a user first clicks on the link, the destination page immediately redirects them to the home page, presumably because there is some kind of user session required (?), I do not know. Not a good user experience for my visitors. The second time you follow the link it displays happily. The chances of my users following a link twice is slim.

Is there a standard URL parameter or something that I can append to tell the ASP platform to generate a user session and not redirect.

To see problem for yourself open this link in a new window, then close it, and repeat. First time it will redirect to home page. Second time does not: http://carfueldata.direct.gov.uk/search-new-or-used-cars.aspx?vid=30392

Was it helpful?

Solution

It looks like they are using session for this purpose. As far as I know there isn't any way to override this.

But you can do some work around for this. Call jQuery ajax function to homepage and redirect on its complete event. While calling the ajax function the cookie (ie session set) will be set on client's browser and after the ajax call redirect user to the page.( The page that won't allow users to visit directly)

<a href="#" onclick="LinkClick()">Click to go</a>

function LinkClick()
{
$.ajax({
        type: "get",
        url: "http://carfueldata.direct.gov.uk",
        dataType: 'jsonp',
        complete: function (msg) {
        window.location.href=" http://carfueldata.direct.gov.uk/search-new-or-used-cars.aspx?vid=30392";
        }
    });
 return false;
}

OTHER TIPS

When you initially submit the request to the website, you receive a 302 status (moved (temporarily)) and a redirect to the home page. This is because there is no session ID cookie in your request. The redirect response from the server creates the session ID cookie for you and from then on, the site honours subsequent requests.

I don't know which client library you are using, but it should be possible to intercept the redirect request sent by the server, and replace the redirect URL to the homepage with your original request URL. Since the redirect response contains the session ID cookie, we can assume that the session has been created and your original request should work immediately without the redundant visit to the home page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top