2
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);
}

This is the code I have written in my main method which is implementation of insert all values of excel sheet into database in mvc3 razor. Now, Please help me how will I show this exception message on view page?

Soner Gönül
  • 94,086
  • 102
  • 195
  • 339
dilipkumar1007
  • 143
  • 3
  • 20

1 Answers1

5

You can always insert the error message in the ViewBag and then show it in the view you display after. But maybe you want a more advanced solution?

ViewBag.MyExeption = theobjectcontainingtheerrorinfoyouwanttosee
Brad Larson
  • 169,393
  • 45
  • 393
  • 567
Sandman
  • 785
  • 6
  • 15
  • keep in mind that this code has been written in main method . I have a separate folder which contain this method and a .exe file which is calling by controller. – dilipkumar1007 Feb 14 '14 at 08:36