Asp.net MVC jQuery ajax .post weird problem: post to server sometimes?
I've encountered a pretty weird situation, I'm using Win7, VS2010, ASP.NET MVC2, jQuery. I have a simple form a textarea and a button doing a .post() ajax call to server, pretty simple setup.
It works when I input plain text in the textarea, but if I mix html tags like bold, then it works sometimes!!
I do have [ValidateInput(false)] on the action method and ValidateRequest="false" on my view, the things is that what I have does work, sometimes.
So when I debug it and mix html tag and submit, it does go into the the action method correctly, sometimes. While other times, like when not in debug, it just does not stop in the action method at all.
Very Werid! Just thought to ask if anyone else had this problem before?
It turns out that make this to work I need to have the following 3 things on my ASP.NET MVC app ready,
- ValidateRequest="false" on the view
- [ValidateInput(false)] on the action method
- <httpRuntime requestValidationMode="2.0"/> on the web.config
The last thing is what I missed, I found this out by using FireBug which returned the entire asp.net Yellow Screen in html in its console.
Interesting thing is that without the last item, when you input html tags in the textarea the app should NOT work but throw some security exception, but it worked when I debugged my app which made the whole thing confusing.