![](/img/trans.png)
[英]How can I Insert an Umbraco Item in to a url in a cshtml file, razor?
[英]URL decode in Razor .NET file (cshtml)
我正在将url编码的数据发布到cshtml文件中。 在发送电子邮件之前,如何解码变量customerEmail
和customerRequest
?
@{
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
对象进行了解码。
你不知道
Request
对象已经为您解码了所有内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.