我在我的MVC3 Razor项目的HomeController.cs中的try catch块中定义了一个方法.现在请告诉我如何在我的视图页面上显示此异常消息?
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剃须刀中的数据库的实现。现在,请帮助我如何在查看页面上显示此异常消息?