Asp.net MVC jQuery ajax.post weird problem: message to server sometimes?

I came across a rather strange situation, I use Win7, VS2010, ASP.NET MVC2, jQuery. I have a simple textarea form and a button that calls a.post () ajax on the server, a fairly simple setup.

It works when I enter plain text in a text box, but if I mix html tags like bold, then it sometimes works !!

I have [ValidateInput (false)] in the action method and ValidateRequest = "false" in my view. The fact is that what I have sometimes works.

So, when I debug it and mix the html tag and submit, it sometimes enters the action method, sometimes. In other cases, for example, when it is not being debugged, it does not stop at all in the method of action.

Very Werid! Just thought to ask if anyone else has this problem?

+3
source share
1 answer

It turns out that this works, I need to have the following 3 things in my ASP.NET MVC application,

  • ValidateRequest="false" in view
  • [ValidateInput(false)] according to the method of action
  • <httpRuntime requestValidationMode="2.0"/> in web.config

The last thing I missed, I found out about this using FireBug, which returned the entire hp address of asp.net Yellow to html in the console.

Interestingly, without the last element, when you enter html tags in a text field, the application should NOT work, but it throws some kind of security exception, but it worked when I debugged my application, which made it all confusing.

0
source

Source: https://habr.com/ru/post/1752943/


All Articles