e-on
e-on

Reputation: 1605

C# - visit url in background

having a brain freeze today.

I'm looking to visit a URL to add tracking information just before my shopping cart gets redirected back to the main page (i.e. just after purchase).

I can't think how I could visit that URL without actually redirecting to my tracking page, and then redirecting again from there back to the homepage. Does anyone know?

This seems like it should be really easy, but I can't seem to get it working.

Thanks

Upvotes: 3

Views: 2967

Answers (4)

Jarlitz
Jarlitz

Reputation: 19

How about using javascript:

function async_url_call(url) {

    xmlHttp = GetXmlHttpObject();

    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

Upvotes: 0

Tejs
Tejs

Reputation: 41256

There are multiple ways:

  1. Put an Iframe or image tag on your homepage after being redirected from your purchase page that requests that url.
  2. Programmatically request the tracking page after purchase on your server.
  3. Make an ajax request from your homepage after being redirected (or before being redirected from your puchase page)

Upvotes: 2

maple_shaft
maple_shaft

Reputation: 10463

Use the HttpWebClient to programattically visit a web page on the server side?

http://msdn.microsoft.com/en-us/library/system.net.webclient(v=vs.80).aspx

Upvotes: 2

WEFX
WEFX

Reputation: 8562

Are you familiar w/ JSON requests? You could hit a URL in the background (and feed it a few parameters) without actually loading a new page.

Upvotes: 1

Related Questions