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

Exception occurred when input data has html code #34

Closed
TWCM opened this issue Mar 12, 2017 · 4 comments
Closed

Exception occurred when input data has html code #34

TWCM opened this issue Mar 12, 2017 · 4 comments
Assignees

Comments

@TWCM
Copy link

TWCM commented Mar 12, 2017

Hi @thepirat000
I got an error when the request form data has html code, the Audit.Mvc.AuditAttribute class method private static IDictionary<string, string> ToDictionary(NameValueCollection col) occur an exception "System.Web.HttpRequestValidationException: 'A potentially dangerous Request.Form value was detected from the client (Html="
").'" , would you help to check this issue?
Below image for your reference.

image

@thepirat000
Copy link
Owner

thepirat000 commented Mar 13, 2017

This is not related to Audit.NET, that's an ASP.NET exception that will be thrown by default whenever you try to access a form value that contains unencoded HTML.
Since you are passing unencoded HTML, when the Audit.NET library tries to access the form value, the exception is thrown.

You can explicitly avoid the exception. For example adding the attribute [ValidateInput(false)] to your controller action, take a look at http://stackoverflow.com/questions/81991/a-potentially-dangerous-request-form-value-was-detected-from-the-client

@TWCM
Copy link
Author

TWCM commented Mar 13, 2017

Here is the code of controller. added the ValidateInput(false) attribute, but still throw exception .

image

@thepirat000
Copy link
Owner

oh ok, let me try to reproduce it here

@thepirat000
Copy link
Owner

You were right, sorry.

I've made a change on the library so the validations will not be triggered by the Audit form values retrieval.

Please upgrade to latest version (>= 7.0.2) and let me know if you still have problems.

Regards

@thepirat000 thepirat000 self-assigned this Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants