Closed davidp1978 closed 5 years ago
Yes, that seems like a bug we should fix , thanks for taking the time to analyze and report it.
Not sure I will get to work on it in the very near future, though. Do you think you could try doing a PR for this one ? Happy to provide guidance and reviews ;)
I'll give a PR a go, I've not done one before so you'll have to bear with me.
No worries, happy to help :)
I was in the same situation 1.5 year ago ;)
I have an old site using ASP.NET web forms and MS ajax. The MS ajax seems to be adding an extra ampersand to the post data: ...&spDummyText2=&ASYNCPOST=true&
I believe this is being translated into a null entry in the Form.AllKeys array. When I try to output form data in the log I get a null reference error. I believe it's the "key.IndexOf" on this line (SerilogWebClassicConfiguration.cs): if (FilterPasswordsInFormData && FilteredKeywordsInFormData.Any(keyword => key.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) != -1))
Here is the top of the stack trace: [NullReferenceException: Object reference not set to an instance of an object.] SerilogWeb.Classic.<>c__DisplayClass38_0.<FilterPasswords>b__0(String keyword) +7 System.Linq.Enumerable.Any(IEnumerable
1 source, Func
2 predicate) +169 SerilogWeb.Classic.SerilogWebClassicConfiguration.FilterPasswords(String key, String value) +121If I don't apply any filter there is no error, the problem is that being the old web forms I have a large __VIEWSTATE that I don't want in the log.
Can a null check on the key variable be added? Or possibly in the calling code something like: configuration.FilterPasswords(k ?? "", v)