动态生成图像的技术可能是将 ASP.NET MVC 控制器添加到 WebForms 项目中,并使用一个操作方法返回一个 FileResult,其中包含动态生成的图像(包含电子邮件地址)。
public class DynamicImageController : System.Web.Mvc.Controller
{
public FileResult Email(int id)
{
// TODO: Code that uses the ID value to retrieve the
// email address for this customer (for example)
}
}
在您的 Web 表单上,您可以使用图像服务器控件,并从后面的代码中相应地设置 ImageUrl (类似于 "/DynamicImage/Email/" + customerId)。
How a about using a simple image that features your email address?
A technique to dynamically generate the image could be to add an ASP.NET MVC controller to your WebForms project with an action method that returns a FileResult containing a dynamically-generated image containing the email address.
public class DynamicImageController : System.Web.Mvc.Controller
{
public FileResult Email(int id)
{
// TODO: Code that uses the ID value to retrieve the
// email address for this customer (for example)
}
}
On your web form you could use an image server control, and set the ImageUrl accordingly (something like "/DynamicImage/Email/" + customerId) from the code behind.
This page has an example illustrating how to use a FileResult to render an image (a chart in this scenario)
The downside with the image-based approach is that it cant be copy-pasted by users.
I think some kind of JavaScript that renders the email would be nice. If it's tricky enough, bots might not be able (or willing) to find it. For example, say that you start with an image (works for everybody). Then, if the user clicks it, it turns into a copy-pasteable text by some JavaScript-magic.
Another idea would be to replace the image with a text 2 seconds after the page has loaded. If bots are in a hurry (are they usually?) they will only see the image. Also, if the user is quick and tried to select the image before it's replaced, the JavaScript can fire right away and replace it with the proper text. Use a mouseover- or click-event or something like that.
Seriously, in my opinion, none of these solutions is worth the extra hassle to your users.
Spam filters are really good these days (I get almost no spam in my gmail, and I always use my email address straight up) and if you want to reach an audience, your priority should be their comfort, not yours.
I'd say an image approach if you don't mind about users not being able to copy it.
You can use JavaScript to build the address from some random algorithm you like. You may also put it in an alert() which is still copy-able but your email address never touches the DOM.
A better approach is to go like google groups , they don't show u the actual email ID , just the beginning , but then , if u are a human , you can use the captcha approach to verify the visitor as a human or a bot . Also , you can have a sound file embedded in your system or a flash based display , which shows your email ID . You can create some actionscript flash , it looks good , attractive and delivers the purpose as well . Either sound or a flash , is what I think looks good . You can even create a dynamic image which keeps on changing every time a user reloads the page . Good luck !
发布评论
评论(10)
superuser.com 上的最新答案解决了这个问题通过比较一系列常用方法来提出问题。
There's a recent answer on superuser.com which addresses this exact question by comparing a whole range of commonly used methods.
我使用过:
I've used:
使用带有您的电子邮件地址的简单图像怎么样?
动态生成图像的技术可能是将 ASP.NET MVC 控制器添加到 WebForms 项目中,并使用一个操作方法返回一个
FileResult
,其中包含动态生成的图像(包含电子邮件地址)。在您的 Web 表单上,您可以使用图像服务器控件,并从后面的代码中相应地设置
ImageUrl
(类似于"/DynamicImage/Email/" + customerId
)。此页面有一个示例,说明如何使用
FileResult
呈现图像(本场景中的图表)http://www.codeproject.com/KB/aspnet/MvcChartControlFileResult.aspx
How a about using a simple image that features your email address?
A technique to dynamically generate the image could be to add an ASP.NET MVC controller to your WebForms project with an action method that returns a
FileResult
containing a dynamically-generated image containing the email address.On your web form you could use an image server control, and set the
ImageUrl
accordingly (something like"/DynamicImage/Email/" + customerId
) from the code behind.This page has an example illustrating how to use a
FileResult
to render an image (a chart in this scenario)http://www.codeproject.com/KB/aspnet/MvcChartControlFileResult.aspx
我开始使用的一种方法是 CSS 代码重定向:
您可以使用某种类型的 String.Reverse 功能(取决于您使用的语言)在页面上插入动态电子邮件地址。
这是最简单有效的方法之一。在这里查看其他一些:https://superuser.com/questions/235937/does-电子邮件地址混淆实际工作
One that I've started using is CSS code redirection:
You could use some type of String.Reverse feature (depending on the language you use) to insert the dynamic e-mail addresses on the page.
This is one of the easiest and effective ways. Check out some others here: https://superuser.com/questions/235937/does-email-address-obfuscation-actually-work
基于图像的方法的缺点是用户无法复制粘贴。
我认为某种能够呈现电子邮件的 JavaScript 会很好。如果它足够棘手,机器人可能无法(或不愿意)找到它。例如,假设您从一张图像开始(适用于每个人)。然后,如果用户单击它,它就会通过某种 JavaScript 魔法变成可复制粘贴的文本。
另一个想法是在页面加载后 2 秒用文本替换图像。如果机器人很匆忙(通常是这样吗?),他们只会看到图像。此外,如果用户很快并尝试在替换图像之前选择图像,则 JavaScript 可以立即触发并将其替换为正确的文本。使用鼠标悬停或单击事件或类似的事件。
The downside with the image-based approach is that it cant be copy-pasted by users.
I think some kind of JavaScript that renders the email would be nice. If it's tricky enough, bots might not be able (or willing) to find it. For example, say that you start with an image (works for everybody). Then, if the user clicks it, it turns into a copy-pasteable text by some JavaScript-magic.
Another idea would be to replace the image with a text 2 seconds after the page has loaded. If bots are in a hurry (are they usually?) they will only see the image. Also, if the user is quick and tried to select the image before it's replaced, the JavaScript can fire right away and replace it with the proper text. Use a mouseover- or click-event or something like that.
Javascript 编码怎么样?可以使用这样的 PHP 函数:(
代码可能需要一些更正,因为我编写时没有检查错误)。
How about Javascript encoding? A PHP function like this could be used:
(the code might need some correcting, as I wrote it without checking for errors).
说真的,在我看来,这些解决方案都不值得为您的用户带来额外的麻烦。
如今,垃圾邮件过滤器确实非常好(我的 Gmail 中几乎没有垃圾邮件,而且我总是直接使用我的电子邮件地址),如果您想吸引受众,您的首要任务应该是他们的舒适度,而不是您的舒适度。
也许这是一个主观问题:)
Seriously, in my opinion, none of these solutions is worth the extra hassle to your users.
Spam filters are really good these days (I get almost no spam in my gmail, and I always use my email address straight up) and if you want to reach an audience, your priority should be their comfort, not yours.
Maybe this is a subjective question though :)
如果您不介意用户无法复制它,我会说使用图像方法。
您可以使用 JavaScript 根据您喜欢的某种随机算法构建地址。您也可以将其放入仍可复制的
alert()
中,但您的电子邮件地址永远不会触及 DOM。I'd say an image approach if you don't mind about users not being able to copy it.
You can use JavaScript to build the address from some random algorithm you like. You may also put it in an
alert()
which is still copy-able but your email address never touches the DOM.更好的方法是像谷歌群组一样,他们不会向您显示实际的电子邮件 ID,只是开始,但是,如果您是人类,您可以使用验证码方法来验证访问者是人类还是机器人。
此外,您还可以在系统中嵌入声音文件或基于闪存的显示器,以显示您的电子邮件 ID。您可以创建一些actionscript flash,它看起来不错、有吸引力并且也达到了目的。
无论是声音还是闪光,都是我觉得好看的。您甚至可以创建一个动态图像,每次用户重新加载页面时该图像都会不断变化。
祝你好运 !
A better approach is to go like google groups , they don't show u the actual email ID , just the beginning , but then , if u are a human , you can use the captcha approach to verify the visitor as a human or a bot .
Also , you can have a sound file embedded in your system or a flash based display , which shows your email ID . You can create some actionscript flash , it looks good , attractive and delivers the purpose as well .
Either sound or a flash , is what I think looks good . You can even create a dynamic image which keeps on changing every time a user reloads the page .
Good luck !
其他人提到使用图像,这里有一篇关于 MakeUseOf 的文章,链接到一个网站,该网站将为您构建这些类型的图像...
Someone else mentioned using an image, here's an article on MakeUseOf that links to a site that will build those types of images for you...
http://www.makeuseof.com/dir/hidetext-easily-convert-text-email-addresses-images/