Question

I have website made in ASP.net MVC3 and hosted images on it. But other websites are using my images links and stealing my bandwidth. Is there a way to check each request using http headers and send different response regarding website name?

Please suggest me a article or help me in this.

Thanks and regards

Was it helpful?

Solution

You can prevent accessing those image by not posting their actual path on your server. Read here

This is how your < img > tag will look like :

<img src="data:image/png;base64,iVBORw0K....." id="pictureFrame"/>

This piece of code will do the job for the image in C#

private void encryptPhoto(string imagePath)
{
    pictureFrame.Src = @"data:image/gif;base64," + EncodePhoto(Server.MapPath(imagePath));
}
private string EncodePhoto(string fileName)
{
        return Convert.ToBase64String(File.ReadAllBytes(fileName));
}

OTHER TIPS

Not that I know of, but what you can do is store a list of the actual image file names in some secret text file and read them in with PHP or something similar to actually display them. Then you can change the image names in the file system and text file so your site will look fine, but you can make the old image files point to new images that say "THIS IMAGE WAS STOLEN FROM [MYDOMAIN]" That should curb the stealing pretty quick.

you can ignore that images using MVC routing. define route pattern as per your requirement.

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("foldername/{filename}.html");
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top