How do you deal with trolling students? This is inspired by the other question about dealing with stupid questions. The popular answers all seemed to assume that the student really wants to hear an answer. While this is a reasonable assumption, and the answers are very good, they don't cover trolls. 

Imagine that you are teaching a computer science lab and a student asks you why our noses run and our feet smell. I agree that you should act professionally no matter what the student does - but what behavior would be considered "professional" in such a situation?
There isn't One Right Way, any more than there is one right way to teach or manage a class room as a whole. I've most taken note of a few styles:


"Old-school" academic style. They state clearly in the rules/syllabus they will treat everyone professionally, with respect, and they expect the same from all students. They will be more than happy to call you out, right then and there, for inappropriate behavior, and they will call a spade a spade without hesitation. They will, if necessary, be so clear and blunt that it will make you cringe, and if the person will not take direction then they will be shown the door - no one is required to be in their class.
Humorist. My dad always use to say, "ask a silly question, get a silly answer." Sometimes its just a fun invitation for a little ad lib comedy. Real smart asses find, if they push it too far, they will quickly end up the focus of the joke in a rather uncomfortable way (some people's version of humor gets very cutting in a hurry). These sorts tend to deal with such people like comics deal with hecklers.
Redirection - judo master. This sort of style will take any question, no matter how assinine, and turn it into a good question that relates to the task at hand. "Why do feet smell? Well, neurobiologists studying sensation often utilize specialized applications of neural networks to improve their understanding, but first we'll need to have a good hold on the fundamentals - which brings me to the next slide on genetic algorithms...any other questions on this slide before we continue?" 
Sweet and simple, KISS. This style would just say, "that's not within the scope of this class, or course. Any other questions about this slide/class/topic?"
Tangential. Maybe you just have extra time or enjoy talking about what they asked about. It has nothing to do with the course, or maybe even anything important, but go ahead and answer the question fully, in depth, with citations, if you know it. Go nuts. Have fun with it, and sometimes you can over-load them with so much knowledge and facts about something they didn't actually care about that they will simply reply with a nod and feel sorry they asked. I'm sufficiently good with this that someone once remarked, "never trifle with someone who has a vastly longer attention span than you do." But obviously you'd better not be pressed for time!
Troll right back (thanks to Shion). Tell them you'll be happy to cover his question next class if he'd like, you think it would make some nice variety to add to the mid-term and comprehensive final. Tell the student you aren't sure of the answer, but you love to learn something new every semester - why don't they look up the answer and prepare a 5-10 minute presentation? You'll even give them a bonus point! You can ask them to email you after class if they'd be interested in the bonus point. If they take you up on it, schedule it for an office hour.


The thing is, most of the time you just really must assume good intent, because otherwise you will - especially if you are not in a fantastic mood - bite someone who genuinely wasn't trying to be unpleasant, or just wanted to be a touch playful. Anything you do to that student will ring much more loudly in the ears of the other students than the one you are addressing.

So be careful to promote a positive environment that encourages other students, rather than one that gets locked in on the one wise-acre who might just be playing a clown for the day.