@{
try
{
WebMail.SmtpServer = "smtp.qq.com";
WebMail.SmtpPort = 465;
WebMail.EnableSsl = true;
WebMail.UserName = "youyiyangcn";
WebMail.Password = "*******";
WebMail.From = "rsvps@example.com";
WebMail.Send("youyiyangcn@qq.com", "RSVP Notification",
Model.Name + " is " + ((Model.WillAttend ?? false) ? "" : "not")
+ "attending");
}
catch (Exception)
{
@:Sorry - we couldn't send the email to confirm your RSVP.
}
}
请问这里的catch(Exception)能否用e.toString的方法把报错的详细信息打印出来?谢谢!
请问这里的catch(Exception)能否用e.toString的方法把报错的详细信息打印出来?谢谢!
可以。这个方法输出的内容比较多:异常类型,消息,堆栈跟踪以及或者嵌套的或者内部异常的所有信息。如果你只是想要打印当前异常的错误信息,你可以使用 Message 属性。简单参考官方文档中的描述:https://learn.microsoft.com/zh-cn/dotnet/api/system.exception?view=net-6.0#exception-type-features