"Don't do it" is not a useful answer to a question of "How do I do XYZ?", unless it is embedded into a section of your response.
I usually break down my "don't do that" responses like this:
- To answer the question
- Why you should not do it that way
In the past, I was working a personal project just to explore some ideas/concepts. I asked "How do I do X in Y situation?" and received dozens of "Don't Do It!!!!" responses, which then got upvoted (downvoted by me), only one poster actually answered my question.
In my case, I specifically stated that I knew it wasn't best practices, I was just trying to explore. Therefore, the flurry of "Don't Do It!" responses were incredibly unhelpful.
So, because this is a technical Q & A site, you should answer the questions as best you can, to tell the OP "Here's how you do that" or "Here's how you would accomplish that task" maybe with a different approach. THEN, only after you've answered the actual question, should you explain why it is not a good idea. Otherwise, you're just scolding people.
EDIT
In response to RSolbergs comment: "It's acceptable if you are answering "Is it okay to do this?""
If someone is asking "is it okay to do this" then yes, you can say "no" as long as you are backing your answer up. That is not the situation I was referring to. In that situation, it doesn't make sense to have a policy that forbids 50% of the answers.
I'm talking about the situation where someone asks "How do I do XYZ?", if you say "Don't do XYZ" you are literally NOT ANSWERING THE QUESTION!
An analogy. If someone yells at you, "Hey, how do I get out if I'm trapped in a well?" and you yell back "Don't Fall In!"
You can then chuckle at how clever you are, and walk away while that person drowns.
EDIT
In response to Shog9 mention of things which should just not be done.
See "Questions with Nefarious Intent".
Stack Overflow is a technical Q & A site. It is not supposed to be the place for the high and mighty to make judgments on the others. If you feel uncomfortable with the question being asked, then you should not answer it.
I had a discussion with a colleague about whether or not it is possible to create a web page which could access the printer directly and print something. He said it was not, I insisted that it was possible. In a million years, neither of us would ever use this on a production app, it would be DISASTROUS. But, the technical question was intruiging to me, so I put it forth to Stack Overflow. I mentioned that I would obviously never do this, and I still recieved "Don't Do It!" responses. Which were, as I've mentioned over and over, completely useless.
For questions that are concerned with limits of technology, and the possibility of creating some functionality when under severe restraints, I would go to Stack Overflow, because the people there are millions of times smarter than I am. However, once I've laid out the technical question, I am looking for a technical answer, not for someone to preach to me.
I don't mind if someone says "This is a bad idea, I would do this instead, but here is an answer to your question" That is fine, because they have still provided an answer. However, if all they can say is "Don't do that" then I'm exactly where I started.
Technical questions deserve technical answers, and Don't do it does not answer the technical question.