dil*_*007 2 c# asp.net-mvc exception razor asp.net-mvc-3
catch(Exception ex)
{
System.Diagnostic.StackTrace st=New System.Diagnostic.StackTrace(ex,true);
System.Diagnostic.StackFrame sf=st.getframe(st.frame-1);
int irow=sf.GetFileLineNumber();
int icol=sf.GetFileColumnNumber();
string smsg="Row: "+irow+ " Col "+icol;
Throw New Exception(smsg, ex);
}
Run Code Online (Sandbox Code Playgroud)
这是我在主要方法中编写的代码,该方法是将excel工作表的所有值插入mvc3剃须刀中的数据库的实现。现在,请帮助我如何在查看页面上显示此异常消息?
小智 5
您始终可以将错误消息插入ViewBag中,然后在随后显示的视图中显示它。但是也许您想要一个更高级的解决方案?
ViewBag.MyExeption = theobjectcontainingtheerrorinfoyouwanttosee
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
945 次 |
| 最近记录: |