C# Programming > Web

C# Link Cloaker

 

What is a link cloaker?

A link cloaker is a handy webpage whose sole purpose of existance is to redirect its visitors to another site.

What's the point of that? Well image you want to send your users to the link www.somepage.com/giantnumbers3952093/morestuff... A long url like that looks unprofessional, can be a hassle to insert or remember, and can have all other sorts of negative impacts.

The solution is to create something nice and short, a single page so we can create a link like www.yourdomain.com/cloakpage.html. That looks a lot better and its branded with your site's name.

Cloaked links are especially popular among online affiliates (eBay being one of the most popular), who use long and cryptic urls.

The link cloaker program helps automatically generate these cloaking webpages. Making the process a lot faster...

How to Redirect a Link - The Types of Cloakers

HTML

Simplest way to redirect a user is with a meta tag:

<meta http-equiv=""Refresh"" content=""0;URL=[original link here]"" />

This method only requires HTML and allows the user to set a delay time. Most, if not all, new browsers support this method. For the ones that don't, add the link to the body of the cloak link.

PHP

A more sophisticated way of redirecting:

<?php
header('Location: [original link here]');
?>

This method is a lot cleaner and does not break the Back button. However the webhost must have PHP support (which most webhosts do). Note: Make sure the lines above are the only thing in the cloak page file or it won't work.

JavaScript

A popular way to redirect traffic is with JavaScript, which most users have enabled:

<script type=""text/javascript"">
<!--
window.location = ""[original link here]""
//-->
</script>

This method is portable and elegant. It's downside is the user must have Javascript enabled on their browser. However if they do not, a workaround is to include the html meta tag between <noscript>[meta redirect here]</noscript> brackets after the Javascript.

What the Program Does

So then what does The Link Cloaker do? It automates generating the redirecting html page. It has an option for each of the above methods described.

In fact there are programs out there in the vast seas of the internet that cost money and do the exact same function. Some are free ones also, but their quality is questionable.

This C# link cloaker is simple and functional. What's even better is with the source code you can add all the bells and whistles of fancier link cloakers and even come up with some of your own.

One look at the source code and you will see the programming is extremely simple. In fact, there's more coding to handle the user interface than anything really. The actual code that modifies the html page is:

htmlCode = htmlCode.Replace("[1]", title);
htmlCode = htmlCode.Replace("[2]", url);
htmlCode = htmlCode.Replace("[3]", description);

You really have to download the C# Link Cloaker project files to see just how easy it all fits together.

Back to C# Article List