0

How do I get current parameter values when an exception occurs inside a random method without having specific code in each method to write out the values?

I need this for ASP.NET MVC and WCF IErrorHandler?

For example given the following code:

public void SomeRandomMethod(Request request, string someRandomString)
{
     throw new Exception();
}

is there a way for an IErrorHandler in WCF or MVC global.asax HttpApplication's Application_Error & Elmah to get the value of the Request object and someRandomString without specifically catching the exception and writing custom logic for each of N number of methods then throwing again?

Maybe this should be broken into 2 questions one for WCF and one for ASP>NET MVC? The request hierarchies seem very similar to me and so I was hoping for a single unified answer.

7
  • No, this is make debugging easier when in production Commented Jul 20, 2012 at 20:59
  • Are you looking for this weblogs.asp.net/pglavich/archive/2008/10/16/… Commented Jul 20, 2012 at 21:06
  • @HatSoft: I don't see anything in that article about getting the parameter values? Commented Jul 20, 2012 at 21:10
  • Are you using any Dependency Injection? For example if you were creating your objects with Unity, this would be easy. Commented Jul 22, 2012 at 7:25
  • @ErnieL - yes, then if would be easy. No, what I am looking for here is something the will work for ALL methods in WCF and ASP.NET applications. I have been looking into the RequestContext and AOP but have not found yet what I am looking for. I think this question is about to go up for bounty. Commented Jul 22, 2012 at 19:10

1 Answer 1

0

I would recommend using Elmah. It's a wonderful logging tool for ASP.NET applications. It will include the parameters passed along with the HTTP request.

Sign up to request clarification or add additional context in comments.

3 Comments

Can you provide an example of how to include this info?
@Kaizen - Just to be clear, are you okay with this information being logged with the exception? Or do you need to see this data at some other point in the page lifecycle?
The parameter values only need to be logged with the exception.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.