我想发送一个URL给一个人。该URL需要包含一个电子邮件地址。基本上,我想要看起来像这样的东西:
http://www.mydomain.com/page.aspx?e=emailAddress@network.com
Run Code Online (Sandbox Code Playgroud)
据我了解,我无法直接通过URL传递电子邮件地址。相反,我需要先对其进行编码。我的理解正确吗?如果是这样,如何使用C#对其进行编码?我看到了各种各样的编码选项,但是我不确定该使用什么。
谢谢!
如果使用C#进行操作,请使用HttpServerUtility.UrlEncode将某些内容编码为url。
从文章:
String MyURL;
MyURL = "http://www.contoso.com/articles.aspx?title=" + Server.UrlEncode("ASP.NET Examples");
Run Code Online (Sandbox Code Playgroud)
或您的情况:
String MyURL = "http://www.mydomain.com/page.aspx?e=" + Server.UrlEncode("emailAddress@network.com");
Run Code Online (Sandbox Code Playgroud)