Request.Url.Authority不返回预期域 [英] Request.Url.Authority doesn't return expected domain
问题描述
我产生在我的网站的控制电子邮件的链接到我的网站:
I'm generating an e-mail in my website's controller with a link to my website:
"http://" & Request.Url.Authority & "/some-page"
当我测试我的本地机器上的这个工程(返回本地主机:12345
)和生产(返回 www.company.com
),但1人得到这个结果:
This works when I tested it on my local machine (returns localhost:12345
) and in production (returns www.company.com
) but 1 person got this as a result:
http://www.company..com/some-page
正如你可以看到在域名为2 ..
。我不能重现此错误,这怎么可能?
As you can see there are 2 ..
in the domain name. I can't reproduce this error, how is this possible?
编辑:一点的更多信息
- 类型的电子邮件我送的是一个纯文本邮件(没有HTML或RTF)
- 网络服务器日志显示www.company.com作为域名有问题的请求提出时
- 我只收到的电子邮件的部分截图。我认为,电子邮件客户端Outlook,但我看不出有什么理由展望将有misinter preTED的链接。
- 这当然是可能的,这个人(或恶意软件)先后编辑这封邮件的内容。
推荐答案
这实际上是与电子邮件是如何被带codeD有问题,看到这个答案:的http://stackoverflow.com/a/6603002/186288 。总之,您应该编码改为UTF8强制电子邮件的基64编码,否则一些电子邮件客户端可以misinter preT默认的内容传输编码:引用打印;编码和在发生打一个包点的网址都添加额外的。
This is actually a problem with how the email is being encoded, see this answer: http://stackoverflow.com/a/6603002/186288. In summary, you should change the encoding to UTF8 to force base-64 encoding of the email, otherwise some email clients can misinterpret the default Content-Transfer-Encoding: Quoted-Printable; encoding and add in extra "."s in URLs that happen to hit a wrap point.
要做到这一点,您发送电子邮件之前添加此行:
To do this, add this line before you send the email:
mail.BodyEncoding = System.Text.Encoding.UTF8;
这篇关于Request.Url.Authority不返回预期域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!