New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request Validation errors does not get logged #217
Comments
Unfortunately, this is due to a breaking change introduced by ASP.NET 4.0. A workaround right now would be to ask ASP.NET to revert back to the older behavior by adding the following to your configuration: <httpRuntime requestValidationMode="2.0" /> This seems to be a valid issue for ELMAH nonetheless as the original exception gets lost and could be addressed by ignoring request validation errors while accessing those collections to capture the context. Reported by @atifaziz on 2011-03-31 19:45:34
|
Reverted in r820 and issue is re-opened. Unfortunately, the fix in r819 seemed promising but further testing showed that it could potentially suppress request input validation for the rest of the request. There seems to be no way to turn request input validation back on post- Reported by @atifaziz on 2011-03-31 23:15:29
|
Any solution how to use Elmah 1.2 release to log
In MVC3 One possible way I found is to trap Reported by |
Another way to get to this issue: ASP.NET4, MVC3 application, and post "potentially dangerous" content to the controller. In my case, it's an XML... The controller action itself is decorated with But if an exception happens (other reason, not caused by the "unsafe" input), Although adding Reported by |
Could you use the if (e is HttpRequestValidationException) {
var unvalidatedRequestValues = request.Unvalidated();
_queryString = CopyCollection(unvalidatedRequestValues.QueryString);
_form = CopyCollection(unvalidatedRequestValues.Form);
} Reported by @davidduffett on 2011-10-27 10:29:12 |
I can see one big fat reason why my comment won't easily work - it would require you to target the .NET 4.0 framework for starters... :-) Reported by @davidduffett on 2011-10-27 10:35:23 |
I've attached a .NET 4.0 workaround that could be used, although changes to the ELMAH API would be required. It would involve referencing System.Web.Abstractions and being able to pass in a Could possibly be used like this: if (exception is HttpRequestValidationException) {
var unvalidatedContext = new UnvalidatedHttpContext(HttpContext.Current);
Elmah.ErrorSignal.FromContext(unvalidatedContext).Raise(exception);
} Reported by @davidduffett on 2011-10-27 11:22:09
|
For anyone else that is interested in this issue I've posted a simple fix to my own fork that does not break the ELMAH public API here: It simply continues to log the exception as normal, without the Reported by @davidduffett on 2011-10-28 09:29:26 |
Reported by @atifaziz on 2012-09-12 15:47:15
|
This fix only applies to ASP.NET 4.0 and later. On ASP.NET 4.0 only, Reported by @atifaziz on 2012-09-14 14:04:22 |
Is there going to be a new Nuget build that will include this fix? Reported by |
We've run into this too, having installed via NuGet - will there be / is there a version of the NuGet package which includes this fix? Reported by |
An updated NuGet package with this fix would have just saved me a couple of hours of frustration. Reported by |
Despite the fix already exists here, there is still no nuget package at So, analyzing the issue I wrote temporary solution which does not require to modify elmah source files. The idea is to inherit from <add name="ErrorLog" type="YourProject.SomeFolder.ElmahErrorLogModuleFix, YourProject"
preCondition="managedHandler" />
<!--and for email module--> In attach you can find fixed modules. Thanks. Reported by
|
I implemented the fix and it works great, except now the Custom Errors Mode will not work. For example, the web config settings below no longer work so you get routed to the default <customErrors mode="On" defaultRedirect="~/Error">
<error statusCode="404" redirect="~/Error" />
<error statusCode="500" redirect="~/Error" />
</customErrors> Has any one else encounter this same concern? And, will there be an updated Nuget Reported by |
I added this line try
{
//FIX STARTS
//Error error = new Error(e, context);
Error error = CreateErrorSafe(e, context);
//FIX ENDS
ErrorLog errorLog = this.GetErrorLog(context);
error.ApplicationName = errorLog.ApplicationName;
error.StatusCode = e is HttpException ? ((HttpException)e).GetHttpCode() : 500;
string id = errorLog.Log(error);
entry = new ErrorLogEntry(errorLog, id, error); Reported by |
This is a workaround for issue elmah#217 (https://code.google.com/p/elmah/issues/detail?id=217 and elmah#217) when running on ASP.NET 4. This is a surgical change to Elmah 1.2 SP2--the current release--and requires running on .NET 4.
What steps will reproduce the problem?
<TEXT>something</TEXT>
(as default for html button content in IE6)What is the expected output? What do you see instead?
The exception should be logged in the normal way
What version of the product are you using? On what operating system?
Version 1.2 Beta
Please provide any additional information below.
Originally reported on Google Code with ID 217
Reported by
laingster
on 2011-03-24 09:09:09The text was updated successfully, but these errors were encountered: