查询字符串中的“&”号弄乱了正文中链接的简单mailto

bro*_*man 2 c# mailto email

我正在尝试在我的C#ASP.Net Web应用程序中做一个简单的mailto。

string url = HttpContext.Current.Request.Url.AbsoluteUri;
System.Diagnostics.Process.Start("mailto:?subject=View Rig Map&body=" + url);
Run Code Online (Sandbox Code Playgroud)

但是,如果网址中的查询字符串带有&符,则分隔名称/值对,例如“ http:// localhost:51771 / MuseumViewer.aspx?MuseumIDs = 3301&CountryIDs = 1”,则该链接在主体中被切断。该电子邮件位于“ http:// localhost:51771 / MuseumViewer.aspx?MuseumIDs = 3301”。

我真的不想做任何花哨的事情,因为我要做的就是在电子邮件正文中添加链接。谁能帮我这个?如果我将mailto放在客户端,会行得通吗?

使用解决方案进行更新 我很难确定要选谁作为答案,但这是我使用的解决方案:

string url = HttpContext.Current.Request.Url.AbsoluteUri;
string link = Server.UrlEncode(url);
System.Diagnostics.Process.Start("mailto:?subject=View Rig Map&body=" + link);
Run Code Online (Sandbox Code Playgroud)

mgi*_*ida 5

%26是&符的URL转义代码。尝试在网址上运行UrlEncode()。