0

There is a system like Clickmeter that allows people to create a smart link for their banner ads. Here is a short explanation of the system. You can enter a URL as the landing page and system gives you back a special URL to put instead of the original. Now if someone clicks on the special link, he will be redirected to the landing page that you wanted to.

I am developing something like that but here is the trouble. I must use 301 redirect because of some SEO things, and 301 redirect is only available in server side as I know. But I want to get some client data such as browser name, operating system model and browser language before redirecting the client. And I am doing this part in javascript, absolutely client side.

I dont know what to do or if I am wrong about something else. But I know that Clickmeter is doing exactly the thing that I want to. They get some client data and then do 301 redirect. Here is a sample link of CLickmeter: http://9nl.it/vz0d

Babak-Na
  • 104
  • 1
  • 1
  • 8
  • Please add code, not links (nobody should go to a link from a question to understand it). And even if you _have to_ add a link, please don't add one that has been obscured with a URL shortener and people cannot tell what's on the other side. – Alvaro Montoro Jul 22 '15 at 10:59
  • Thank you for your comment @AlvaroMontoro. The links that I put in the question is for someone who wants to know more about the issue. The question is simple. I am looking for 301 redirecting and getting client side data in a same time. Thank you again for your attention – Babak-Na Jul 22 '15 at 11:12

1 Answers1

0

You don't get the client's data in the client's side. You do it in the server side by reading and processing the Request.UserAgent before doing the 301 redirection:

// get the User Agent
string userAgentText = HttpContext.Current.Request.UserAgent;

// Process the User Agent, and extract the information you want: browser, OS, version...
...

// Make the 301 redirection to the target URL programmatically
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", TARGET_URL);

You could get similar information in JavaScript by using window.navigator.userAgent (and AJAX to send the data on click), but I would not recommend this solution for two reasons reasons:

  • If you are providing just a URL (your service sounds like a URL shortener), you cannot inject the JavaScript code.
  • If the user has JavaScript disabled, this solution will not work at all.

To find more information on how this could be done, read these questions:

Community
  • 1
  • 1
Alvaro Montoro
  • 28,081
  • 7
  • 57
  • 86