βӔḺ*_*ⱫŌŔ 6 .net c# exception webmatrix razor
我来自带有桌面应用程序的C#背景,主要是用于Web的PHP,我认为使用Razor代码可以执行类似的操作来显示异常消息(就像在桌面应用程序中一样):
@{
// Other code....
try
{
WebMail.Send(to: "talk@@blah.com",
subject: "New message from - " + email,
body: message
);
<p>Thanks for your message. We'll be in touch shortly!</p>
}
catch(Exception exception)
{
<p>exception.Message;</p> // Why doesn't this display exception details?
}
}
Run Code Online (Sandbox Code Playgroud)
注意:我故意在那里放两个@来强制异常,所以我可以看到如何显示异常消息.
当您使用 <p>标签时,剃刀引擎退出c#模式并进入html模式.尝试
<p>@exception.Message;</p>
Run Code Online (Sandbox Code Playgroud)
在拦截区.
| 归档时间: |
|
| 查看次数: |
6568 次 |
| 最近记录: |