gpt4 book ai didi

c# - Razor .NET 文件 (cshtml) 中的 URL 解码

转载 作者:太空宇宙 更新时间:2023-11-03 17:52:19 25 4
gpt4 key购买 nike

我正在将 url 编码数据发布到 cshtml 文件。如何在发送电子邮件之前解码变量 customerEmailcustomerRequest

@{
var customerEmail = Request["customerEmail"];
var customerRequest = Request["customerRequest"];

var errorMessage = "";
var debuggingFlag = false;
try {
// Initialize WebMail helper
WebMail.SmtpServer = "your-SMTP-host";
WebMail.SmtpPort = 25;
WebMail.UserName = "your-user-name-here";
WebMail.Password = "your-account-password";
WebMail.From = "your-email-address-here";

// Send email
WebMail.Send(to: customerEmail,
subject: "Dashboard Feedback from - " + customerEmail,
body: customerRequest
);
}
catch (Exception ex ) {
errorMessage = ex.Message;
}
}

最佳答案

使用 System.Web.dll 您可以解码信息:HttpUtility.UrlDecode .

例子:

String foo = "foo%40bar.com";
String bar = HttpUtility.UrlDecode(foo);
// bar = "foo@bar.com"

但我要提一下,传入的信息应该已经通过 Request 对象进行了解码。

关于c# - Razor .NET 文件 (cshtml) 中的 URL 解码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21143110/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com