I have requirement of validating user input in a text box. Whenever a html tag is entered it should display the same view with friendly error message like "Cannot enter html tags."
The ways I have tried so far are:
- [ValidateInput(true)] on the Controller- It comes up with error "Potentially dangerous request"
- [ValidateInput(false)] on the Controller- It stores the value in the database-(I don't want this)
- In the view Model I placed a tag for the property
[RegularExpression ( "<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>",ErrorMessage = "You have entered html…Html is not a valid input!" )]
any one had this this issue. If yes please let me know, how have you fixed that.
Thank you