Determine in which Event i'm in

Hi There, just want to know if it's possible to determine in which event i'm in...

I want to create a error logging system, and in my try...catch statement, in the Catch(ex as Exception) part I want to write an error to a database table... but to make things easier, I want to record the current event, in which page i'm in, and all those stuff, just to make things easier for debugging, after the website has been launched, and any unforeseen errors that might pop up along the way...

Thanks

SJB



Answer this question

Determine in which Event i'm in

  • MickJ

    The Method you are looking for is System.Reflection.MethodBase.GetCurrentMethod()

    public static System.Reflection.MethodBase GetCurrentMethod()

    Member of System.Reflection.MethodBase

    Summary:Returns a MethodBase object representing the currently executing method.Return Values:

    A MethodBase object representing the currently executing method.

    or

    You can use the stack trace as Svenc suggest



  • cssjm

    This sounds like a web application to me...perhaps you'd be better served by going to the ASP.NET forums... http://forums.asp.net



  • KluchCode

    Hi,

    just save ex.ToString() it includes the complete call stack.

    --
    SvenC


  • hanumanth

    Thanks, i'll give it a shot...

    so there is no way to do a response.write(get_event) and then let it return, for example, eg: Page_Load


  • Catalin Zima

    Thanks,

    but in the end vb.net is vb.net...

    and the code will not differ from Window apps to Web apps...


  • Mr Pro Tools

    sjb wrote:

    Thanks,

    but in the end vb.net is vb.net...

    and the code will not differ from Window apps to Web apps...

    Well, in VB there is no page_load or response object... so it is different. There's a reason for a separate forum: yes, some code is the same, but the techniques for doing things can be completely different. So, to avoid confusion, there's a separate ASP.NET forum (which covers both VB and C#).



  • Determine in which Event i'm in