Not only is it permitted, it is actively encouraged.
As the founder of Stack Exchange, Jeff Atwood, said long ago:
I do it all the time! For example, when I ran into a nasty issue with Java exploits in Google Chrome when browsing for images, I documented that on Super User by asking and answering my own question. Now, others can benefit from my misfortune -- and best of all, I got new even better answers beyond what I offered! Overall, a huge win all around.
There are some things to consider, however.
Your question should contain just the question, and your answer should contain just the answer. Don't put your solution in with your question. They should both stand alone.
(To make this convenient, there's even a checkbox below the question text area to let you answer your question at the same time you ask it.)
Your question and answer will be considered separately. It should be a good, well-crafted question that anyone with the knowledge could answer. If you post an overly-simple question that lacks the details for an answer, it's going to be downvoted. The same with your answer. Both should be good quality, independent of the other.
Note, also, that it's quite likely that someone will have an alternative way of doing what you're describing and may have their own answer. Their answer may even be better than yours.
I'd also suggest that you want to be sure that your question (and answer) will be about something that will be useful to others. A question that's so basic that no one would ever need to ask it, or for a problem that is so esoteric that virtually no one else would ever think to ask about it, probably won't be received well.
Given all that, however, if you have a problem that you solved yourself that is likely to help others, by all means share it.