私はSystem.Web.Services.WebService
いくつかの を含んでいWebMethods
ます。これらのいずれかでWebMethods
例外が発生した場合は、その WebMethod に渡された値をログに記録したいと考えています。パラメータの数やタイプに関係なく同じメソッドを使用できるように、十分に汎用的な方法でこれを処理したいと考えています。生の JSON をログに記録すると思っていましたが、アクセス方法がわかりません。Context.Request オブジェクト (InputStream
プロパティを含む) 全体を検索しましたが、見つかりませんでした。
これが私がやりたいことです:
[WebMethod(EnableSession = true)]
public IEnumerable MyWebMethod(int a, string b)
{
try
{
//do something
}
catch (Exception e)
{
LogException(e, this.Context);
throw;
}
}
//All WebMethods should be able to call LogExceoption regardless of param type/count
protected void LogException(Exception ex, HttpContext context)
{
string parameters = context.Request. //?? i don't know how to get to the JSON
//write exception detail to log
}
.net Framework 3.5 で C# を使用しています