In general, yes. Questions should be self-contained, i.e. all information must be in the question itself and not depend on external links (which may break).
There are exceptions, though. If the pastebin is 1000 lines long, the question doesn't become any clearer just by pasting the code itself; the OP needs to provide an MCVEMCVE, not just a code dump. Another exception would be a case like this:
Can you please fix my code?
in which, even with code, it is unclear what the OP is asking.