Skip to content
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

Ability to view actual HTTP POST request details #164

Open
atifaziz opened this issue Aug 25, 2015 · 5 comments
Open

Ability to view actual HTTP POST request details #164

atifaziz opened this issue Aug 25, 2015 · 5 comments

Comments

@atifaziz
Copy link
Member

atifaziz commented Aug 25, 2015

What new or enhanced feature are you proposing?

This is similar to Issue #124 except that I'd like to view POST or request details on the webpage rather than the email.

Instead of limiting it, I'd rather have it show everything included in the request. Ideally, this would create a namevaluecollection to simply display all form fields and their submitted values.

What goal would this enhancement help you achieve?

I'd be able to inspect bad HTTP requests so I can see if people are inputting "invalid" data that is really valid.


Reported by kamran.ayub on 2010-03-27 16:24:18

@atifaziz
Copy link
Member Author

atifaziz commented Aug 25, 2015

I'm relatively new to elmah but I believe what you're looking for is the Raw/Source data which is available via XML or JSON. I use the XML but it does display the name/value pairs for form where the error was thrown.

Hope that helps.


Reported by jason.gladstone on 2011-01-10 05:29:12

@MarkPerryBV
Copy link

MarkPerryBV commented Jul 25, 2016

We are using elmah on most of our web projects and I would find it very useful for the error email to contain the RAW request body.

We do not use traditional form posts as I am posting JSON in the request body to the server (Single Page Application).

Most of the generated errors are for POST actions (asp.net MVC) and without the request body it's very difficult to debug. Since we also run a web farm going to the elmah.axd page can be tricky.

Any thoughts?

@atifaziz
Copy link
Member Author

atifaziz commented Jul 25, 2016

@MarkPerryBV Have a look at my answer to a similar question on StackOverflow: “Elmah: How to get JSON HTTP request body from error report?

I'm quoting it here for reference and search-ability:

ELMAH so far only logs the context or information that is peripheral to the request and which can be conveniently captured in a standard way. Forms are arguably a special treatment because ASP.NET already does the job of decoding and memorizing request entities when the MIME type is application/x-www-form-urlencoded. JSON requests on the other hand are prolematic because at the time an exception occurs, the input stream (HttpRequest.InputStream) may have been partially or completely consumed by a JSON decoder. ELMAH would not be able to get a second crack at it for the purpose of logging. You will therefore have to make sure that you buffer the input stream or text before passing it through any JSON decoder and stash it away somewhere like HttpContext.Items. You could then try to recover the buffered data and attach it to an outgoing mail at the time of an error. ELMAH currently does not support attaching arbitrary data to a logged error. There is however the ErrorLogModule that has a Logged event and which supplies the Id of the logged error. This could be used to store the input data elsewhere (perhaps in another table if you are using a back-end database for the error logs) but tie it back to the logged error by maintaining an association via the Id.

@MarkPerryBV
Copy link

I think what I might try is adding an ActionFilter to my MVC controller actions which stores a copy of the RequestBody in HttpContext.Items to be able to attach to the Error Email as advised.

@atifaziz
Copy link
Member Author

@MarkPerryBV Would be awesome if you can share your findings/solution once your attempt comes to a conclusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants