Kassapa, a naked ascetic, asks the Buddha a series of questions about the source of pain and to each of his questions receives the response, 'it is not such as that.' When Kassapa asks for an explanation, The Buddha teaches him the 'Doctrine Going Down the Middle': that is, the Pa.ticca Samuppaada, the chain of interdependent factors giving rise to the experience of individualized existence and the resulting pain.
Read the Sutta
Index of Available translations: SN 2.12.17
An excellent sutta for sharpening your understanding of the Pa.ticca Samuppaada,, the idea of 'not-self, and the theories or views of eternalism and annihiliationism.'
The idea that one and the same individual does a deed and experiences the consequence implies the continuity of that individual from the time of the doing of the deed to the time of the receiving of the consequences and can be seen to be in error because it can be seen that there is no thing there which is the self or which has existence which is continuous from the doing of a deed to the receiving of the consequences.
The idea that one individuality does the deed and another indivituality experiences the consequence (both identified by that individuality as 'my self') implies the extinction of the self that does the deed without the experience of the consequences which is another way of saying that there is no experiencing of the consequences of intentionally done deeds and that the pain that one experiences is a matter of chance and that consequently there could be no escape from pain.
Since it can be seen that pain is a result of identification with the doing of deeds done with the intent to create identified-with experience of the consequences, and that there is escape from pain by not doing such intentional deeds, that theory is seen to be incorrect.
The resolution of the dilemma is to wake up to the fact that there is no thing there that can be called the 'self' and see the process:
Blindness to the process results in own-making, own-making results in identified-with experience of old age, sickness, suffering and death, grief and lamentation, pain and misery, and despair.
Note, while we are speaking about the 'Middle Way' that here that term refers to the Pa.ticca Samuppada, where in the First Sutta, it refers to the Magga. What does this tell us? It tells us that these two things are equivalants. See if you can see how this can be.