sun197 / elmah

Automatically exported from code.google.com/p/elmah
Apache License 2.0
0 stars 0 forks source link

Errors not recorded with dangerous form data #333

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm using ELMAH in my mvc project to record errors. I realised that sometimes 
errors not recorded. So I wrapped the statements in try..catch and called:
ErrorSignal.FromCurrentContext().Raise(ex);

but nothing get recorded again for that specific error. So I tried to step into 
ELMAH source code (using Reflector VS addin). And I saw this exception in elmah:

 A potentially dangerous Request.Form value was detected from the client (Text="<br>").
 StackTrace:    at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)

Actual source code: this._form = CopyCollection(request.Form); in public 
Error(System.Exception e, HttpContext context) in Error.cs. and CopyCollection 
method:

private static NameValueCollection CopyCollection(NameValueCollection 
collection)
{
    if ((collection != null) && (collection.Count != 0))
    {
        return new NameValueCollection(collection);
    }
    return null;
}
So .Net does not allow creating new NameValueCollection from dangerous form 
data. I have a lot of Html editors in my application and I want ELMAH to record 
errors in any situation.

What can I do?

Original issue reported on code.google.com by Mahmood....@gmail.com on 17 Jun 2013 at 11:54

GoogleCodeExporter commented 8 years ago
I posted a question in StackOverflow:
http://stackoverflow.com/questions/17131836/errors-not-recorded-in-elmah

Original comment by Mahmood....@gmail.com on 17 Jun 2013 at 11:57

GoogleCodeExporter commented 8 years ago
StackOverflow or the ELMAH Discussion Group[1] are the right places to ask your 
question as opposed to the issue tracker.

[1] http://groups.google.com/group/elmah

Original comment by azizatif on 17 Jun 2013 at 4:37