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
  • 97,193
  • 102
  • 206
  • 364
dilipkumar1007
  • 329
  • 4
  • 22

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
  • 170,088
  • 45
  • 397
  • 571
Sandman
  • 795
  • 7
  • 16
  • 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